void CreateRegisteredPackageSources(List <PackageSource> packageSources, FakePropertyService propertyService) { fakeSettingsFactory = new FakeSettingsFactory(); fakeSettingsFactory.FakeSettings.AddFakePackageSources(packageSources); registeredPackageSources = new RegisteredProjectTemplatePackageSources( propertyService, fakeSettingsFactory); }
void CreateCache() { fakeMainCache = new FakePackageRepositoryFactory(); var propertyService = new FakePropertyService(); fakeSettingsFactory = new FakeSettingsFactory(); registeredPackageSources = new RegisteredProjectTemplatePackageSources(propertyService, fakeSettingsFactory); cache = new ProjectTemplatePackageRepositoryCache(fakeMainCache, registeredPackageSources); }
public void PackageSource_PropertyServiceDefinesDataFolder_ReturnsDataTemplatePackagesFolder() { FakePropertyService propertyService = CreateFakePropertyService(); propertyService.DataDirectory = @"d:\sharpdevelop\data"; CreateDefaultPackageSource(propertyService); var packageSource = defaultPackageSource.PackageSource; string sourceDirectory = @"d:\sharpdevelop\data\templates\packages"; var expectedPackageSource = new PackageSource(sourceDirectory, "Default"); Assert.AreEqual(expectedPackageSource, packageSource); }
public void TestList_ShouldLoadAllPropertiesAndAssignToViewModel() { //Arrange var service = new FakePropertyService(); var controller = new RentController(service); var properties = new RentalProperty[0]; service.PropertiesToReturn = properties; //Act var result = (ViewResult)controller.List(); //Assert Assert.AreEqual(properties, result.ViewData.Model); }
public void TestCreate_ShouldSaveProperty() { //Arrange var service = new FakePropertyService(); var controller = new RentController(service); CreateControllerContextStubFor(controller); //Must setup ControllerContext, as method under test needs asscess to Controller.Resuest //Act var propertyToCreate = new RentalProperty(); controller.Create(propertyToCreate); //Assert Assert.AreEqual(propertyToCreate, service.LastCreatedProperty); }
public void PackageSources_OnePredefinedPackageSource_RegisteredPackageSourceIsPredefinedPackageSource() { FakePropertyService propertyService = CreatePropertyService(); propertyService.DataDirectory = @"d:\sharpdevelop\data"; var expectedPackageSources = new List <PackageSource>(); expectedPackageSources.Add(new PackageSource("http://sharpdevelop", "Test")); CreateRegisteredPackageSources(expectedPackageSources, propertyService); RegisteredPackageSources actualPackageSources = registeredPackageSources.PackageSources; PackageSourceCollectionAssert.AreEqual(expectedPackageSources, actualPackageSources); }
public void TestCreate_ShouldReturnPropertyPartialView_ForAjaxRequest() { //Arrange var service = new FakePropertyService(); var controller = new RentController(service); CreateControllerContextStubFor(controller); controller.Request.Stub(r => r["X-Requested-With"]).Return("XMLHttpRequest"); //make it Ajax request //Act var propertyToCreate = new RentalProperty(); var result = (PartialViewResult)controller.Create(propertyToCreate); //Assert Assert.AreEqual("PropertyPartial", result.ViewName); }
public void PackageSources_NoPredefinedPackageSources_PackageSourceConfigLookedForInUserFolder() { FakePropertyService propertyService = CreatePropertyService(); propertyService.DataDirectory = @"d:\sharpdevelop\data"; propertyService.ConfigDirectory = @"c:\Users\test\AppData\ICSharpCode\SharpDevelop4.1"; var packageSources = new List <PackageSource>(); CreateRegisteredPackageSources(packageSources, propertyService); IEnumerable <PackageSource> actualPackageSources = registeredPackageSources.PackageSources; string directory = fakeSettingsFactory.DirectoryPassedToCreateSettings; string expectedDirectory = @"c:\Users\test\AppData\ICSharpCode\SharpDevelop4.1\templates"; Assert.AreEqual(expectedDirectory, directory); }
public void PackageSources_NoPredefinedPackageSources_DefaultPackageSourceCreated() { FakePropertyService propertyService = CreatePropertyService(); propertyService.DataDirectory = @"d:\sharpdevelop\data"; var packageSources = new List <PackageSource>(); CreateRegisteredPackageSources(packageSources, propertyService); RegisteredPackageSources actualPackageSources = registeredPackageSources.PackageSources; var expectedPackageSources = new PackageSource[] { new PackageSource(@"d:\sharpdevelop\data\templates\packages", "Default") }; PackageSourceCollectionAssert.AreEqual(expectedPackageSources, actualPackageSources); }
public void TestCreate_ShouldRedirectToListView_ForNonAjaxRequest() { //Arrange var service = new FakePropertyService(); var controller = new RentController(service); CreateControllerContextStubFor(controller); controller.Request.Stub(r => r["X-Requested-With"]).Return(""); //make it Non-Ajax request //Act var propertyToCreate = new RentalProperty(); var result = controller.Create(propertyToCreate); //Assert //Assert.AreEqual("List", result.RouteValues["action"]); result.Assert(Redirect.To.Action("List")); //controller.Assert(HasError.On("Name").WithMessage("Error Message")); //result.Assert(Direct.To.DefaultView()); //result.Assert(Direct.To.View("SomeView")); //result.Assert(Redirect.To.Controller("SomeController").Action("SomeAction")); }
void CreateDefaultPackageSource(FakePropertyService propertyService) { defaultPackageSource = new DefaultProjectTemplatePackageSource(propertyService); }