Search Results

Search found 582 results on 24 pages for 'nunit addins'.

Page 21/24 | < Previous Page | 17 18 19 20 21 22 23 24  | Next Page >

  • Error CS0117: Namespace.A does not contain definition for Interface..

    - by SnOrfus
    I'm getting the error: 'Namespace.A' does not contain a definition for 'MyObjectInterface' and no extension method 'MyObjectInterface' accepting a first argument of type ... I've looked at this and this and neither seems to apply. The code looks like: public abstract class Base { public IObject MyObjectInterface { get; set; } } public class A : Base { /**/ } public class Implementation { public void Method() { Base obj = new A(); obj.MyObjectInterface = /* something */; // Error here } } IObject is defined in a separate assembly, but: IObject is in a separate assembly/namespace Base and A are in the same assembly/namespace each with correct using directives Implementation is in a third separate assembly namespace, also with correct using directives. Casting to A before trying to set MyObjectInterface doesn't work Specifically, I'm trying to set the value of MyObjectInterface to a mock object (though, I created a fake instead to no avail) I've tried everything I can think of. Please help before I lose more hair. edit I can't reproduce the error by creating a test app either, which is why I'm here and why I'm frustrated. @Reed Copsey: /* something */ is either an NUnit.DynamicMock(IMailer).MockInstance or a Fake object I created that inherits from IObject and just returns canned values. @Preet Sangha: I checked and no other assembly that is referenced has a definition for an IObject (specifically, it's called an IMailer). Thing is that intellisense picks up the Property, but when I compile, I get CS0117. I can even 'Go To Definition' in the implementation, and it takes me to where I defined it.

    Read the article

  • MonoRail: Testing, Route Extensions, Folder Structures

    - by Kezzer
    I've got a few questions related to the use of MonoRail Testing Does everyone tend to use NUnit for their testing? I haven't worked enough with testing to know if this is a good testing framework to use. I'm just looking to get more into testing my applications a lot more than before and wanted to know if there's any general guidelines. Are you supposed to copy the controller over to a test area and just rename it with test in the name and re-run it? How do you ensure your test project and main project coincide with one another? Is it just a case of copying everything over again or are there tools available to do it for you? Route Extensions MonoRail tends to use <action>.rails, can you omit the .rails part if you configure your routing correctly? Why does this seem to be the standard? Folder Structures I haven't found anywhere which really points out your standard folder structure. Sure, you have Controllers, Models, and Views. But your Models folder should contain your data access objects as well. I've seen some have something like -> Models -> DaoClasses -> Entities But what about custom structures used to get data out of views? And if you're using NHibernate, where's a good place to stick the mappings? I know it's entirely dependent on the developer, but I haven't really seen any standard approach. Cheers

    Read the article

  • When can a == b be false and a.Equals(b) true?

    - by alastairs
    I ran into this situation today. I have an object which I'm testing for equality; the Create() method returns a subclass implementation of MyObject. MyObject a = MyObject.Create(); MyObject b = MyObject.Create(); a == b; // is false a.Equals(b); // is true Note I have also over-ridden Equals() in the subclass implementation, which does a very basic check to see whether or not the passed-in object is null and is of the subclass's type. If both those conditions are met, the objects are deemed to be equal. The other slightly odd thing is that my unit test suite does some tests similar to Assert.AreEqual(MyObject.Create(), MyObject.Create()); // Green bar and the expected result is observed. Therefore I guess that NUnit uses a.Equals(b) under the covers, rather than a == b as I had assumed. Side note: I program in a mixture of .NET and Java, so I might be mixing up my expectations/assumptions here. I thought, however, that a == b worked more consistently in .NET than it did in Java where you often have to use equals() to test equality.

    Read the article

  • MVC UI with Mock Controllers?

    - by Jaimal Chohan
    I'm working with Aspnet MVC 2 (R2) and at the same time playing about with the whole alt.net stack. One of this things I would like to be able todo is basically write my Views, and be able to interact with them without having to write the controller logic. E.g. I have a view that displays a list of orders and I can click on an order which redirects to another view where I can edit it, but I don't want to get into the nitty gritty of writing the code to actually get a list of orders, or update an existing ordes. I want to do so I can write UI tests in WaitN/AOT/Selenium without having to worry about whats happening underneath, and also It would help drive my controller logic on a need basis as opposed to guess work based of of the supplied screenshots How do you guys accomplish this atm? Can you provide links ot useful blog posts/tools/framework/articles with information on how to accomplish this p.s. I primarly use Rhino Mocks & NUnit but can happliy change to other tools if they support the above better.

    Read the article

  • nhibernate error recovery

    - by Berryl
    I downloaded Rhino Security today and started going through some of the tests. Several that run perfectly in isolation start getting errors after one that purposely raises an exception runs though. Here is that test: [Test] public void EntitesGroup_CanCreate() { var group = _authorizationRepository.CreateEntitiesGroup("Accounts"); _session.Flush(); _session.Evict(group); var fromDb = _session.Get<EntitiesGroup>(group.Id); Assert.NotNull(fromDb); Assert.That(fromDb.Name, Is.EqualTo(group.Name)); } And here are the tests and error messages that fail: [Test] public void User_CanSave() { var ayende = new User {Name = "ayende"}; _session.Save(ayende); _session.Flush(); _session.Evict(ayende); var fromDb = _session.Get<User>(ayende.Id); Assert.That(fromDb, Is.Not.Null); Assert.That(ayende.Name, Is.EqualTo(fromDb.Name)); } ----> System.Data.SQLite.SQLiteException : Abort due to constraint violation column Name is not unique [Test] public void UsersGroup_CanCreate() { var group = _authorizationRepository.CreateUsersGroup("Admininstrators"); _session.Flush(); _session.Evict(group); var fromDb = _session.Get<UsersGroup>(group.Id); Assert.NotNull(fromDb); Assert.That(fromDb.Name, Is.EqualTo(group.Name)); } failed: NHibernate.AssertionFailure : null id in Rhino.Security.Tests.User entry (don't flush the Session after an exception occurs) Does anyone see how I can reset the state of the in memory SQLite db after the first test? I changed the code to use nunit instead of xunit so maybe that is part of the problem here as well. Cheers, Berryl

    Read the article

  • Visual Studio 2008 / ASP.NET 3.5 / C# -- issues with intellisense, references, and builds

    - by goober
    Hey all, Hoping you can help me -- the strangest thing seems to have happened with my VS install. System config: Windows 7 Pro x64, Visual Studio 2008 SP1, C#, ASP.NET 3.5. I have two web site projects in a solution. I am referencing NUnit / NHibernate (did this by right-clicking on the project and selecting "Add Reference". I've done this for several projects in the past). Things were working fine but recently stopped working and I can't figure out why. Intellisense completely disappears for any files in my App_Code directory, and none of the references are recognized (they are recognized by any file in the root directory of the web site project. Additionally, pretty simple commands like the following (in Page_Load) fail (assume TextBox1 is definitely an element on the page): if (Page.IsPostBack) { str test1; test1 = TextBox1.Text; } It says that all the page elements are null or that it can't access them. At first I thought it was me, but due to the combination of issues, it seems to be Visual Studio itself. I've tried clearing the temp directories & rebuilding the solution. I've also tried tools -- options -- text editor settings to ensure intellisense is turned on. I'd appreciate any help you can give! Thanks, Sean

    Read the article

  • Precision error on matrix multiplication

    - by Wam
    Hello all, Coding a matrix multiplication in my program, I get precision errors (inaccurate results for large matrices). Here's my code. The current object has data stored in a flattened array, row after row. Other matrix B has data stored in a flattened array, column after column (so I can use pointer arithmetic). protected double[,] multiply (IMatrix B) { int columns = B.columns; int rows = Rows; int size = Columns; double[,] result = new double[rows,columns]; for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { unsafe { fixed (float* ptrThis = data) fixed (float* ptrB = B.Data) { float* mePtr = ptrThis + row*rows; float* bPtr = ptrB + col*columns; double value = 0.0; for (int i = 0; i < size; i++) { value += *(mePtr++) * *(bPtr++); } result[row, col] = value; } } } } } Actually, the code is a bit more complicated : I do the multiply thing for several chunks (so instead of having i from 0 to size, I go from localStart to localStop), then sum up the resulting matrices. My problem : for a big matrix I get precision error : NUnit.Framework.AssertionException: Error at (0,1) expected: <6.4209571409444209E+18> but was: <6.4207619776304906E+18> Any idea ?

    Read the article

  • How do I unit test controllers for an asp.net mvc site that uses StructureMap and NHibernate?

    - by Jim Geurts
    I have an asp.net mvc2 application that is using StructureMap 2.6 and NHibernate 3.x. I would like to add unit tests to the application but am sort of at a loss for how to accomplish it. Say I have a basic controller called Posts that has an action called Index. The controller looks something like: public class PostsController : Controller { private readonly IPostService _postService; public PostsController(IPostService postService) { _postService = postService; } public ActionResult Index() { return View(_postService.QueryOver<Post>().Future()); } } If I wanted to create an nunit test that would verify that the index action is returning all of the posts, how do I go about that? If mocking is recommended, do you just assume that interaction with the database will work? Sorry for asking such a broad question, but my web searches haven't turned up anything decent for how to unit test asp.net mvc actions that use StructureMap (or any other IOC) and NHibernate. btw, if you don't like that I return a QueryOver object from my post service, pretend it is an IQueryable object. I'm using it essentially in the same way.

    Read the article

  • What's the best practice to setup testing for ASP.Net MVC? What to use/process/etc?

    - by melaos
    hi there, i'm trying to learn how to properly setup testing for an ASP.Net MVC. and from what i've been reading here and there thus far, the definition of legacy code kind of piques my interests, where it mentions that legacy codes are any codes without unit tests. so i did my project in a hurry not having the time to properly setup unit tests for the app and i'm still learning how to properly do TDD and unit testing at the same time. then i came upon selenium IDE/RC and was using it to test on the browser end. it was during that time too that i came upon the concept of integration testing, so from my understanding it seems that unit testing should be done to define the test and basic assumptions of each function, and if the function is dependent on something else, that something else needs to be mocked so that the tests is always singular and can be run fast. Questions: so am i right to say that the project should have started with unit test with proper mocks using something like rhino mocks. then anything else which requires 3rd party dll, database data access etc to be done via integration testing using selenium? because i have a function which calls a third party dll, i'm not sure whether to write a unit test in nunit to just instantiate the object and pass it some dummy data which breaks the mocking part to test it or just cover that part in my selenium integration testing when i submit my forms and call the dll. and for user acceptance tests, is it safe to say we can just use selenium again? Am i missing something or is there a better way/framework? i'm trying to put in more tests for regression testing, and to ensure that nothing breaks when we put in new features. i also like the idea of TDD because it helps to better define the function, sort of like a meta documentation. thanks!! hope this question isn't too subjective because i need it for my case.

    Read the article

  • Working around "one executable per project" in Visual C# for many small test programs

    - by Kevin Ivarsen
    When working with Visual Studio in general (or Visual C# Express in my particular case), it looks like each project can be configured to produce only one output - e.g. a single executable or a library. I'm working on a project that consists of a shared library and a few application, and I already have one project in my solution for each of those. However, during development I find it useful to write small example programs that can run one small subsystem in isolation (at a level that doesn't belong in the unit tests). Is there a good way to handle this in Visual Studio? I'd like to avoid adding several dozen separate projects to my solution for each small test program I write, especially when these programs will typically be less than 100 lines of code. I'm hoping to find something that lets me continue to work in Visual Studio and use its build system (rather than moving to something like NAnt). I could foresee the answer being something like: A way of setting this up in Visual Studio that I haven't found yet A GUI like NUnit's graphical runner that searches an assembly for classes with defined Main() functions that you can select and run A command line tool that lets you specify an assembly and a class with a Main function to run

    Read the article

  • What is SSIS order of data transformation component method calls

    - by Ron Ruble
    I am working on a custom data transformation component. I'm using NUnit and NMock2 to test as I code. Testing and getting the custom UI and other features right is a huge pain, in part because I can't find any documentation about the order in which SSIS invokes methods on the component at design time as well as runtime. I can correct the issues readily enough, but it's tedious and time consuming to unregister the old version, register the new version, fire up the test ssis package, try to display the UI, get an obscure error message, backtrace it, modify the component and continue. One of the big issues involves the UI component needing access to the componentmetadata and buffermanager properties of the component at design time, and what I need to provide for to support properties that won't be initialized until after the user enters them in the UI. I can work through it; but if someone knows of some docs or tips that would speed me up, I'd greatly appreciate it. The samples I've found havn't been much use; they seem to be directed to showing off cool stuff (Twitter, weather.com) rather than actual work. Thanks in advance.

    Read the article

  • How do I change the base class at runtime in C#?

    - by MatthewMartin
    I may be working on mission impossible here, but I seem to be getting close. I want to extend a ASP.NET control, and I want my code to be unit testable. Also, I'd like to be able to fake behaviors of a real Label (namely things like ID generation, etc), which a real Label can't do in an nUnit host. Here a working example that makes assertions on something that depends on a real base class and something that doesn't-- in a more realistic unit test, the test would depend on both --i.e. an ID existing and some custom behavior. Anyhow the code says it better than I can: public class LabelWrapper : Label //Runtime //public class LabelWrapper : FakeLabel //Unit Test time { private readonly LabelLogic logic= new LabelLogic(); public override string Text { get { return logic.ProcessGetText(base.Text); } set { base.Text=logic.ProcessSetText(value); } } } //Ugh, now I have to test FakeLabelWrapper public class FakeLabelWrapper : FakeLabel //Unit Test time { private readonly LabelLogic logic= new LabelLogic(); public override string Text { get { return logic.ProcessGetText(base.Text); } set { base.Text=logic.ProcessSetText(value); } } } [TestFixture] public class UnitTest { [Test] public void Test() { //Wish this was LabelWrapper label = new LabelWrapper(new FakeBase()) LabelWrapper label = new LabelWrapper(); //FakeLabelWrapper label = new FakeLabelWrapper(); label.Text = "ToUpper"; Assert.AreEqual("TOUPPER",label.Text); StringWriter stringWriter = new StringWriter(); HtmlTextWriter writer = new HtmlTextWriter(stringWriter); label.RenderControl(writer); Assert.AreEqual(1,label.ID); Assert.AreEqual("<span>TOUPPER</span>", stringWriter.ToString()); } } public class FakeLabel { virtual public string Text { get; set; } public void RenderControl(TextWriter writer) { writer.Write("<span>" + Text + "</span>"); } } //System Under Test internal class LabelLogic { internal string ProcessGetText(string value) { return value.ToUpper(); } internal string ProcessSetText(string value) { return value.ToUpper(); } }

    Read the article

  • Automatic Deployment of Windows Application

    - by dileepkrishnan
    Hi, We have setup continuos integration in our development environment using SVN, CC.Net, MSBuild and Nunit. Now, we want to automate the process of moving (copying) builds from one stage to another like this: Whenever a new build succeeds in Dev, that should be copied automatically to the QA server (a folder on the QA server, to be exact) Whenever a QA build succeeds tests in QA, that QA build should be copied to the UAT server (a folder on the UAT server, to be exact). This should be implemented as a process (a CC task, for example) which we can start when QA succeeds. Whenever a UAT build succeeds tests in UAT, that should be copied to the PROD server (a folder on the PROD server, to be exact). This should be implemented as a process (a CC task, for example) which we can start when UAT succeeds. How do I implement this? Can this be done using CC.Net alone? Or, can this be done using MSBuild? Or, do I need to employ both? Please advise what exactly needs to be done. Thanks Dileep Krishnan

    Read the article

  • Issues with intellisense, references, and builds in Visual Studio 2008

    - by goober
    Hoping you can help me -- the strangest thing seems to have happened with my VS install. System config: Windows 7 Pro x64, Visual Studio 2008 SP1, C#, ASP.NET 3.5. I have two web site projects in a solution. I am referencing NUnit / NHibernate (did this by right-clicking on the project and selecting "Add Reference". I've done this for several projects in the past). Things were working fine but recently stopped working and I can't figure out why. Intellisense completely disappears for any files in my App_Code directory, and none of the references are recognized (they are recognized by any file in the root directory of the web site project. Additionally, pretty simple commands like the following (in Page_Load) fail (assume TextBox1 is definitely an element on the page): if (Page.IsPostBack) { str test1; test1 = TextBox1.Text; } It says that all the page elements are null or that it can't access them. At first I thought it was me, but due to the combination of issues, it seems to be Visual Studio itself. I've tried clearing the temp directories & rebuilding the solution. I've also tried tools -- options -- text editor settings to ensure intellisense is turned on. I'd appreciate any help you can give!

    Read the article

  • Accessing Web.config directly in ASP.NET MVC 1

    - by Neil T.
    I'm trying to implement integration testing in my ASP.NET MVC 1.0 solution. The technologies in use are LINQ-to-SQL, NUnit and WatiN. I recently discovered a pattern that will allow me to create a testing version of the database on the fly without modifying the development version of the database. I needed this behavior in order to run my user interface tests in WatiN that may modify the database. The plan is to modify the connection string in the Web.config file, and pass that new connection string to the DataContext constructor. This way, I don't have to add routes or modify my URLs in order to perform the integration testing. I've set up the project so that the test setup can modify the connection string to point to the test database when the tests are running. The connection string is stored in web.config. The problem I'm having is that when I try to run the tests, I get a NullReferenceException when trying to access the HTTPContext. From everything that I have read so far, the HTTPContext is only available within the context of a controller. Here is the code for the property that is supposed to give me the reference to the Web.config file: private System.Configuration.Configuration WebConfig { get { ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); // NullReferenceException occurs on this line. fileMap.ExeConfigFilename = HttpContext.Current.Server.MapPath("~\\web.config"); System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); return config; } } Is there something that I am missing in order to make this work? Is there a better way to accomplish what I'm trying to achieve?

    Read the article

  • This is a great job opportunity!!! [closed]

    - by Stuart Gordon
    ASP.NET MVC Web Developer / London / £450pd / £25-£50,000pa / Interested contact [email protected] ! As a web developer within the engineering department, you will work with a team of enthusiastic developers building a new ASP.NET MVC platform for online products utilising exciting cutting edge technologies and methodologies (elements of Agile, Scrum, Lean, Kanban and XP) as well as developing new stand-alone web products that conform to W3C standards. Key Responsibilities and Objectives: Develop ASP.NET MVC websites utilising Frameworks and enterprise search technology. Develop and expand content management and delivery solutions. Help maintain and extend existing products. Formulate ideas and visions for new products and services. Be a proactive part of the development team and provide support and assistance to others when required. Qualification/Experience Required: The ideal candidate will have a web development background and be educated to degree level in a Computer Science/IT related course plus ASP.NET MVC experience. The successful candidate needs to be able to demonstrate commercial experience in all or most of the following skills: Essential: ASP.NET MVC with C# (Visual Studio), Castle, nHibernate, XHTML and JavaScript. Experience of Test Driven Development (TDD) using tools such as NUnit. Preferable: Experience of Continuous Integration (TeamCity and MSBuild), SQL Server (T-SQL), experience of source control such as Subversion (plus TortioseSVN), JQuery. Learn: Fluent NHibernate, S#arp Architecture, Spark (View engine), Behaviour Driven Design (BDD) using MSpec. Furthermore, you will possess good working knowledge of W3C web standards, web usability, web accessibility and understand the basics of search engine optimisation (SEO). You will also be a quick learner, have good communication skills and be a self-motivated and organised individual.

    Read the article

  • Should the code being tested compile to a DLL or an executable file?

    - by uriDium
    I have a solution with two projects. One for project for the production code and another project for the unit tests. I did this as per the suggestions I got here from SO. I noticed that in the Debug Folder that it includes the production code in executable form. I used NUnit to run the tests after removing the executable and they all fail trying to find the executable. So it definitely is trying to find it. I then did a quick read to find out which is better, a DLL or an executable. It seems that an DLL is much faster as they share memory space where communication between executables is slower. Unforunately our production code needs to be an exectuable. So the unit tests will be slightly slower. I am not too worried about that. But the project does rely on code written in another library which is also in executable format at the moment. Should the projects that expose some sort of SDK rather be compiled to an DLL and then the projects that use the SDK be compiled to executable?

    Read the article

  • bool as object vs string as object testing equality

    - by Ray Pendergraph
    I am relatively new to C# and I noticed something interesting today that I guess I have never noticed or perhaps I am missing something. Here is an NUnit test to give an example: object boolean1 = false; object booloan2 = false; Assert.That(boolean1 == booloan2); This unit test fails, but this one passes: object string1 = "string"; object string2 = "string"; Assert.That(string1 == string2); I'm not that surprised in and of itself that the first one fails seeing as boolean1 and boolean2 are different references. But it is troubling to me that the first one fails and the second one passes. I read (on MSDN somewhere) that some magic was done to the String class to facilitate this. I think my question really is why wasn't this behavior replicated in bool? As a note... if the boolean1 and 2 are declared as "bool" then there is no problem. Does anyone know the reason for these differences or why it was implemented that way? Can anyone think of a situation where you would want to reference a bool object for anything except its value?

    Read the article

  • Lightcore IoC is returning the same instance when it should give a new one

    - by Anthony
    I have the following code using the lightcore IoC container. But it fails with "NUnit.Framework.AssertionException: Contained objects are equal" which indicates that the objects that should be transient, are not. Is this a bug in lightcore, or am I doing it wrong? [Test] public void JellybeanDispenserHasNewInstanceEachTimeWithDefault() { var builder = new ContainerBuilder(); builder.Register<IJellybeanDispenser, VanillaJellybeanDispenser>(); builder.Register<SweetVendingMachine>().ControlledBy<TransientLifecycle>(); builder.Register<SweetShop>(); builder.DefaultControlledBy<TransientLifecycle>(); IContainer container = builder.Build(); SweetShop sweetShop = container.Resolve<SweetShop>(); SweetShop sweetShop2 = container.Resolve<SweetShop>(); Assert.IsFalse(ReferenceEquals(sweetShop, sweetShop2), "Root objects are equal"); Assert.IsFalse(ReferenceEquals(sweetShop.SweetVendingMachine, sweetShop2.SweetVendingMachine), "Contained objects are equal"); Assert.IsFalse(ReferenceEquals(sweetShop.SweetVendingMachine.JellybeanDispenser, sweetShop2.SweetVendingMachine.JellybeanDispenser), "services are equal"); } PS: I would tag this question with "lightcore", but suddenly my reputation isn't good enough to make a new tag. Huh.

    Read the article

  • Automated test, build and deploy

    - by mike79
    I have visual studio team suite 2008. I was unable to meet the requirements to setup TFS, so I'm using TortoiseSvn and VisualSvn as my version contol in VSTS. I need the system setup to do the following: I neeed to be able to create and track workitems. When updates are made to the current project worked on in VSTS, the updates will be commited back to version control. Tests will be run to see that updates don't break the application. If there's a problem with the update it will be reported back to the developer. If there's no problem with the app, which is a clickonce application, it will automatically be built and deployed to an ftp server. I've never worked with version control, build servers, automated testing and continous intergration. I need to know what needs to be put in place for this type of system. I don't know which combination/stack I should be using: CC.net, TeamCity, Hudson, NAnt, NUnit, MsTest, Trac, BugTracker.net, Ndepend, VisualSvn Server, Perforce, Msdeploy, SCM. I want something that is free/opensource and relatively easy to setup and use. Please suggest a setup that will fit my needs. Any help appreciated

    Read the article

  • wpf progress bar slows 10x times serial port communications... how could be possible that?

    - by D_Guidi
    I know that this could look a dumb question, but here's my problem. I have a worker dialog that "hides" a backgroundworker, so in a worker thread I do my job, I report the progress in a standard way and then I show the results in my WPF program. The dialog contains a simply animated gif and a standard wpf progress bar, and when a progress is notified I set Value property. All lokks as usual and works well for any kind of job, like web service calls, db queries, background elaboration and so on. For my job we use also many "couplers", card readers that reads data from smart card, that are managed with native C code that access to serial port (so, I don't use .NET SerialPort object). I have some nunit tests and I read a sample card in 10 seconds, but using my actual program, under the backgroundworker and showing my worker dialog, I need 1.30 minutes to do the SAME job. I struggled into problem for days until I decide to remove the worker dialog, and without dialog I obtain the same performances of the tests! So I investigated, and It's not the dialog, not the animated gif, but the wpf progress bar! Simply the fact that a progress bar is shown (so, no animation, no Value set called, nothing of nothing) slows serialport communicatitons. Looks incredible? I've tested this behavior and it's exactly what happens.

    Read the article

  • ASP.Net MVC TDD using Moq

    - by Nicholas Murray
    I am trying to learn TDD/BDD using NUnit and Moq. The design that I have been following passes a DataService class to my controller to provide access to repositories. I would like to Mock the DataService class to allow testing of the controllers. There are lots of examples of mocking a repository passed to the controller but I can't work out how to mock a DataService class in this scenerio. Could someone please explain how to implement this? Here's a sample of the relevant code: [Test] public void Can_View_A_Single_Page_Of_Lists() { var dataService = new Mock<DataService>(); var controller = new ListsController(dataService); ... } namespace Services { public class DataService { private readonly IKeyedRepository<int, FavList> FavListRepository; private readonly IUnitOfWork unitOfWork; public FavListService FavLists { get; private set; } public DataService(IKeyedRepository<int, FavList> FavListRepository, IUnitOfWork unitOfWork) { this.FavListRepository = FavListRepository; this.unitOfWork = unitOfWork; FavLists = new FavListService(FavListRepository); } public void Commit() { unitOfWork.Commit(); } } } namespace MyListsWebsite.Controllers { public class ListsController : Controller { private readonly DataService dataService; public ListsController(DataService dataService) { this.dataService = dataService; } public ActionResult Index() { var myLists = dataService.FavLists.All().ToList(); return View(myLists); } } }

    Read the article

  • C# error casting from double to int32

    - by orfix
    using NUF = NUnit.Framework; [NUF.Test]public void DifferentCastingTest() { NUF.Assert.That((int)0.499999D, NUF.Is.EqualTo(0)); NUF.Assert.That((int)0.500000D, NUF.Is.EqualTo(0)); // !!! row 1 NUF.Assert.That((int)1.499999D, NUF.Is.EqualTo(1)); NUF.Assert.That((int)1.500000D, NUF.Is.EqualTo(1)); // !!! row 2 NUF.Assert.That(System.Convert.ToInt32(0.499999D), NUF.Is.EqualTo(0)); NUF.Assert.That(System.Convert.ToInt32(0.500000D), NUF.Is.EqualTo(0)); // !!! NUF.Assert.That(System.Convert.ToInt32(1.499999D), NUF.Is.EqualTo(1)); NUF.Assert.That(System.Convert.ToInt32(1.500000D), NUF.Is.EqualTo(2)); //!!! row 3 } The same double value (1.5D) is converted in different way by casting and Convert.ToInt32 (see row 2 and 3), and two double with same mantissa (0.5 and 1.5) is rounded in different mode (see row 1 and 2). Is it a bug?

    Read the article

  • Is the Subversion 'stack' a realistic alternative to Team Foundation Server?

    - by Robert S.
    I'm evaluating Microsoft Team Foundation Server for my customer, who currently uses Visual SourceSafe and nothing else. They have explicitly expressed a desire to implement a more rigid and process-driven environment as their application is in production and they have future releases to consider. The particular areas I'm trying to cover are: Configuration management (e.g., source control) Change management (workflow and doco for change requests, tasks) Release management (builds and deployments) Incident and problem management (issues and bugs) Document management (similar to source control, but available via web) Code analysis constraints on check-ins A testing framework Reporting Visual Studio 2008 integration TFS does all of these things quite well, but it's expensive and complex to maintain, and the inexpensive Workgroup edition doesn't scale. We don't get TFS as part of our MSDN subscription. Those problems can be overcome, but before I tell my customer to go the TFS route, which in itself isn't a terrible thing, I wanted to evaluate the alternatives. I know Subversion is often suggested for its configuration management/source control, but what about the other areas? Would a combination of Subversion/NUnit/Wiki/CruiseControl/NAnt/something else satisfy all of these requirements? What tools do I need to include in my evaluation? Or should I just bite the bullet and go with TFS since we're already invested in the Microsoft stack?

    Read the article

  • Can I read an Outlook (2003/2007) PST file in C#?

    - by Andy May
    Is it possible to read a .PST file using C#? I would like to do this as a standalone application, not as an Outlook addin (if that is possible). If have seen other SO questions similar to this mention MailNavigator but I am looking to do this programmatically in C#. I have looked at the Microsoft.Office.Interop.Outlook namespace but that appears to be just for Outlook addins. LibPST appears to be able to read PST files, but this is in C (sorry Joel, I didn't learn C before graduating). Any help would be greatly appreciated, thanks! EDIT: Thank you all for the responses! I accepted Matthew Ruston's response as the answer because it ultimately led me to the code I was looking for. Here is a simple example of what I got to work (You will need to add a reference to Microsoft.Office.Interop.Outlook): using System; using System.Collections.Generic; using Microsoft.Office.Interop.Outlook; namespace PSTReader { class Program { static void Main () { try { IEnumerable<MailItem> mailItems = readPst(@"C:\temp\PST\Test.pst", "Test PST"); foreach (MailItem mailItem in mailItems) { Console.WriteLine(mailItem.SenderName + " - " + mailItem.Subject); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); } private static IEnumerable<MailItem> readPst(string pstFilePath, string pstName) { List<MailItem> mailItems = new List<MailItem>(); Application app = new Application(); NameSpace outlookNs = app.GetNamespace("MAPI"); // Add PST file (Outlook Data File) to Default Profile outlookNs.AddStore(pstFilePath); MAPIFolder rootFolder = outlookNs.Stores[pstName].GetRootFolder(); // Traverse through all folders in the PST file // TODO: This is not recursive, refactor Folders subFolders = rootFolder.Folders; foreach (Folder folder in subFolders) { Items items = folder.Items; foreach (object item in items) { if (item is MailItem) { MailItem mailItem = item as MailItem; mailItems.Add(mailItem); } } } // Remove PST file from Default Profile outlookNs.RemoveStore(rootFolder); return mailItems; } } } Note: This code assumes that Outlook is installed and already configured for the current user. It uses the Default Profile (you can edit the default profile by going to Mail in the Control Panel). One major improvement on this code would be to create a temporary profile to use instead of the Default, then destroy it once completed.

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24  | Next Page >