void SetUpCurrentVersion(long version, List<long> appliedVersions, bool assertRollbackIsCalled, bool includeBad) { var providerMock = new DynamicMock(typeof (ITransformationProvider)); providerMock.SetReturnValue("get_MaxVersion", version); providerMock.SetReturnValue("get_AppliedMigrations", appliedVersions); providerMock.SetReturnValue("get_Logger", new Logger(false)); if (assertRollbackIsCalled) providerMock.Expect("Rollback"); else providerMock.ExpectNoCall("Rollback"); _migrator = new Migrator((ITransformationProvider) providerMock.MockInstance, Assembly.GetExecutingAssembly(), false); // Enlève toutes les migrations trouvée automatiquement _migrator.MigrationsTypes.Clear(); _upCalled.Clear(); _downCalled.Clear(); _migrator.MigrationsTypes.Add(typeof (FirstMigration)); _migrator.MigrationsTypes.Add(typeof (SecondMigration)); _migrator.MigrationsTypes.Add(typeof (ThirdMigration)); _migrator.MigrationsTypes.Add(typeof (FourthMigration)); _migrator.MigrationsTypes.Add(typeof (SixthMigration)); if (includeBad) _migrator.MigrationsTypes.Add(typeof (BadMigration)); }
public static DynamicMock NewMockIErrorRenderer(string name, int hashcode) { DynamicMock res; res = new DynamicMock(name, typeof(IErrorDisplay)); res.SetReturnValue("Equals", true); res.SetReturnValue("GetHashCode", hashcode); return (res); }
public void setUp() { m_PossibleMoves = new List<Point> {new Point(2, 3)}; m_BoardView = new StubBoardView(); m_MockModel = new DynamicMock(typeof (IBoardModel)); m_BoardController = new BoardController(m_BoardView); m_MockModel.SetReturnValue("GetPossibleMovesFor", m_PossibleMoves); m_MockModel.SetReturnValue("GetBoard", r_ExpectedData); m_MockModel.SetReturnValue("GetCurrentColor", eCoinType.Black); m_EventListener = new DynamicMock(typeof (IBoardEventListener)); m_BoardController.setEventListener((IBoardEventListener)m_EventListener.MockInstance); m_BoardController.SetModel((IBoardModel)m_MockModel.MockInstance); m_BoardController.setPlayers(new StubPlayer(), new StubPlayer()); }
public void GetProvincesWithoutResult() { DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.SetReturnValue("GetProvinces",new List<Province>()); LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationServices = new LocationServices(locationsManager); Assert.AreEqual(0,locationServices.GetProvinces().Count); }
public void SearchParameters_With_No_SelectedFilters_Return_Only_Actives_And_Visibles() { var searchParameterMock = new DynamicMock(typeof(ISearchParameters<Publication>)); searchParameterMock.SetReturnValue("get_SelectedFilters", null); var solrQueryBuilder = new SolrQueryBuilder<Publication>((ISearchParameters<Publication>)searchParameterMock.MockInstance); var query = solrQueryBuilder.BuildQuery(); Assert.IsTrue(query.Query.Equals("publication_state_id:Active AND publication_visible:true")); }
void SetUpCurrentVersion(int version, bool assertRollbackIsCalled) { var providerMock = new DynamicMock(typeof (ITransformationProvider)); providerMock.SetReturnValue("get_CurrentVersion", version); providerMock.SetReturnValue("get_Logger", new Logger(false)); if (assertRollbackIsCalled) providerMock.Expect("Rollback"); else providerMock.ExpectNoCall("Rollback"); _migrationLoader = new MigrationLoader((ITransformationProvider) providerMock.MockInstance, Assembly.GetExecutingAssembly(), true); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.FirstMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.SecondMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.ThirdMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.ForthMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.BadMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.SixthMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.NonIgnoredMigration)); }
public void CreateIntegrationRequestQueue() { queue = new ProcessorQueue(); processorMock1 = new DynamicMock(typeof(IProcessor)); processorMock1.SetReturnValue("get_Name", "Processor1"); processor1 = (IProcessor)processorMock1.MockInstance; processorMock2 = new DynamicMock(typeof(IProcessor)); processorMock2.SetReturnValue("get_Name", "Processor2"); processor2 = (IProcessor)processorMock2.MockInstance; }
public void Details_Action_Should_Return_Correct_View_Model() { var agencyIndexServiceMock = new DynamicMock(typeof(IndexServiceAgencySolrImpl)); var publicationIndexServiceMock = new DynamicMock(typeof(IndexServicePublicationSolrImpl)); var agency = new Agency { Address = "Direccion", Name = "agencia prueba", UserId = 1 }; var agencysPublication1 = new Publication { VehicleMakeText = "Ford", UserUid = agency.UserId }; var agencysPublication2 = new Publication { VehicleMakeText = "Peugeot", UserUid = agency.UserId }; var listPublications = new List<Publication> { agencysPublication1, agencysPublication2 }; var listAgency = new List<Agency> { agency }; agencyIndexServiceMock.SetReturnValue("Query", listAgency); publicationIndexServiceMock.SetReturnValue("Query",listPublications); var agencyController = new AgencyController { AgencyIndexService = (IndexServiceAgencySolrImpl)agencyIndexServiceMock.MockInstance, PublicationIndexService = (IndexServicePublicationSolrImpl)publicationIndexServiceMock.MockInstance, }; var viewResult = agencyController.Details("abrahamautomotores"); Assert.IsNotNull(viewResult); Assert.NotNull(viewResult.ViewData["Title"]); Assert.True(viewResult.ViewData["Title"].ToString() == "Concesionaria abrahamautomotores"); Assert.NotNull(viewResult.ViewData["Publications"]); Assert.True(((List<Publication>)viewResult.ViewData["Publications"]).Count == listPublications.Count); Assert.True(((List<Publication>)viewResult.ViewData["Publications"])[0].VehicleMakeText == listPublications[0].VehicleMakeText); }
public void Setup() { _errorBrowser = new TestingErrorBrowser(); _mockStackDisplay = MockHelper.NewMockIErrorRenderer("StackTraceDisplay", 1); _mockStackDisplay.SetReturnValue("Text", "Display actual stack trace"); _stackTraceChanged = false; _errorBrowser.StackTraceSourceChanged += new EventHandler(_errorBrowser_StackTraceSourceChanged); return; }
public void SearchParameters_With__SelectedFilters_With_NoName_Return_SelectedFilterException() { var selectedFilters = new List<SelectedFilter> { new SelectedFilter(string.Empty, "val1", true, 1) }; var searchParameterMock = new DynamicMock(typeof(ISearchParameters<Publication>)); searchParameterMock.SetReturnValue("get_SelectedFilters", selectedFilters); var solrQueryBuilder = new SolrQueryBuilder<Publication>((ISearchParameters<Publication>)searchParameterMock.MockInstance); solrQueryBuilder.BuildQuery(); }
public void TestDeleteCity() { List<City> cities = new List<City>(); City city = new City { Name = "New York", DistrictId = 12 }; DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.ExpectAndReturn("AddCity", 3,city); dynamicMock.SetReturnValue("GetCities", cities); dynamicMock.Expect("DeleteCityById", 2); LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); locationService.DeleteCity(2); Assert.AreEqual(3, locationService.AddCity(city)); Assert.AreEqual(0, locationService.GetCities().Count); }
public void SimpleFilters_And_EmptyRangeFilter_Should_Not_Throw_SelectedFilterException() { var selectedFilters = new List<SelectedFilter> { new SelectedFilter("sl1", "val1", true, 1), new SelectedFilter("sl2", "val2", true, 1), new SelectedFilter("sl3", "-", true, 1) }; var searchParameterMock = new DynamicMock(typeof(ISearchParameters<Publication>)); searchParameterMock.SetReturnValue("get_SelectedFilters", selectedFilters); var solrQueryBuilder = new SolrQueryBuilder<Publication>((ISearchParameters<Publication>)searchParameterMock.MockInstance); solrQueryBuilder.BuildQuery(); }
public void CacheProvider_Goto_Database_Once() { var sliceDaoMock = new DynamicMock(typeof (ISliceDao)); sliceDaoMock.SetReturnValue("Get","name"); var sliceCacheProvider = new SliceCacheProvider { Cache = new Spring.Caching.NonExpiringCache(), SliceDao = (ISliceDao)sliceDaoMock.MockInstance }; var name = sliceCacheProvider.GetName("facet", "slice"); Assert.IsTrue(name=="name"); Assert.IsTrue(sliceCacheProvider.Cache.Count==1); }
public void SetUp() { Panel fakeStackControl = new Panel(); Panel fakeCodeControl = new Panel(); _mockStack = new DynamicMock(typeof(IStackTraceView)); _mockCode = new DynamicMock(typeof(ICodeView)); _mockStack.SetReturnValue("ToControl", fakeStackControl); _mockCode.SetReturnValue("ToControl", fakeCodeControl); _code = new TestingCode( (IStackTraceView)_mockStack.MockInstance, (ICodeView)_mockCode.MockInstance); return; }
public void GetProvincesWhithResults() { List<Province> provinces = new List<Province> { new Province(), new Province(), new Province(), new Province() }; DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.SetReturnValue("GetProvinces", provinces); LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationServices = new LocationServices(locationsManager); Assert.AreEqual(4, locationServices.GetProvinces().Count); }
public void SetUp() { _emptyToolbar = new ErrorToolbar(); _filledToolbar = new ErrorToolbar(); _rawMock = MockHelper.NewMockIErrorRenderer("raw", 1); _rawMock.SetReturnValue("get_PluginItem", new ToolStripButton()); _raw = (IErrorDisplay)_rawMock.MockInstance; _browserMock = MockHelper.NewMockIErrorRenderer("browser", 2); _browserMock.SetReturnValue("get_PluginItem", new ToolStripButton()); _browser = (IErrorDisplay)_browserMock.MockInstance; _filledToolbar.Register(_raw); _filledToolbar.Register(_browser); _rendererChangeNotification = false; _filledToolbar.SelectedRendererChanged += new EventHandler(_filledToolbar_SelectedRendererChanged); return; }
public void Banner_Tohtml_Should_Not_Be_Empty() { var keywordsProviderMock = new DynamicMock(typeof (IKeywordsProvider)); var parametersReturn = "kw_marcas=val1&kw_MarcMod=val2&kw_provincias=val3&kw_localidades=val4"; keywordsProviderMock.SetReturnValue("GetParametersString",parametersReturn); var banner = new Banner { KeywordsProvider = (IKeywordsProvider) (keywordsProviderMock.MockInstance), Behaviour = "parametros", Zone = "zone", Provider = "eplanning" }; var html = banner.GetHtml(); Assert.IsFalse(string.IsNullOrEmpty(html)); Assert.IsTrue(html.Contains(parametersReturn)); }
public void FindAllEconomicActivitiesWhithoutResult() { _dynamicMock = new DynamicMock(typeof(EconomicActivityManager)); List<EconomicActivity> activities = new List<EconomicActivity> (); _dynamicMock.SetReturnValue("SelectAllEconomicActivities", activities); _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance; _economicActivityServices = new EconomicActivityServices(_economicActivityManager); Assert.AreEqual(0, _economicActivityServices.FindAllEconomicActivities().Count); }
public void TestSavingIsValid_InitialAmountCorrect() { // Assert.Ignore(); SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User { Id = 6 }, TimeProvider.Today, _savingsProduct, null) { InterestRate = 0.13, FlatWithdrawFees = 3, FlatTransferFees = 3, DepositFees = 5, CloseFees = 6, ManagementFees = 7, AgioFees = 6 }; Client client = new Person { Id = 6, LastName = "El Fanidi", Branch = new Branch()}; _savingManagerMock = new DynamicMock(typeof(SavingManager)); _savingEventManagerMock = new DynamicMock(typeof(SavingEventManager)); DynamicMock connectionMock = new DynamicMock(typeof(SqlConnection)); DynamicMock transactionMock = new DynamicMock(typeof(SqlTransaction)); connectionMock.SetReturnValue("BeginTransaction", transactionMock.MockInstance); _savingManagerMock.SetReturnValue("GetConnection", connectionMock.MockInstance); _savingManagerMock.ExpectAndReturn("GetNumberOfSavings", 1, 6); _savingManagerMock.ExpectAndReturn("Add", 1, saving, client, transactionMock.MockInstance); _savingServices = new SavingServices( (SavingManager)_savingManagerMock.MockInstance, (SavingEventManager)_savingEventManagerMock.MockInstance, new User { Id = 6 } ); try { Assert.GreaterOrEqual(_savingServices.SaveContract(saving, client), 0); saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User { Id = 6 }, TimeProvider.Today, _savingsProduct, null) { InterestRate = 0.13, FlatWithdrawFees = 3, FlatTransferFees = 3, DepositFees = 5, CloseFees = 6, ManagementFees = 7, AgioFees = 6 }; _savingManagerMock.ExpectAndReturn("GetNumberOfSavings", 2, 6); _savingManagerMock.ExpectAndReturn("Add", 2, saving, client, transactionMock.MockInstance); Assert.GreaterOrEqual(_savingServices.SaveContract(saving, client), 0); } catch (OpenCbsSavingException exception) { Assert.Fail(exception.Code.ToString()); } }
public void FindAllInstalments_Result() { DynamicMock mockInstalmentManager = new DynamicMock(typeof(InstallmentManager)); List<KeyValuePair<int, Installment>> list = new List<KeyValuePair<int, Installment>> { new KeyValuePair<int, Installment>(1, new Installment()), new KeyValuePair<int, Installment>(2, new Installment()) }; mockInstalmentManager.SetReturnValue("SelectInstalments", list); LoanServices loanServices = new LoanServices((InstallmentManager)mockInstalmentManager.MockInstance, null, null); Assert.AreEqual(2, loanServices.FindAllInstalments().Count); }
public void TestDeleteProvinceWithoutDistrictIn() { Province provinceOne = new Province(2, "Pekin"); Province provinceTwo = new Province(8, "Qhinghua"); List<District> districts = new List<District> { new District("Paris",provinceOne), new District("Pekin",provinceOne), new District("Pau",provinceOne) }; DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.SetReturnValue("GetDistricts", districts); dynamicMock.Expect("DeleteProvinceById", 8); LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); Assert.AreEqual(true, locationService.DeleteProvince(provinceTwo)); }
public void TestGetCitiesWhithResults() { List<City> cities = new List<City> { new City(), new City(), new City() }; DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.SetReturnValue("GetCities", cities); LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationServices = new LocationServices(locationsManager); Assert.AreEqual(3, locationServices.GetCities().Count); }
public void TestGetDistrictsWhithResults() { List<District> districts = new List<District> { new District(), new District(), new District() }; DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.SetReturnValue("GetDistricts", districts); LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationServices = new LocationServices(locationsManager); Assert.AreEqual(3, locationServices.GetDistricts().Count); }
public void TestUpdateCity() { City city = new City {Name = "Pekin", DistrictId = 12}; List<City> cities = new List<City> {city}; DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager)); mockLocationsManager.ExpectAndReturn("AddCity", 3, city); mockLocationsManager.SetReturnValue("GetCities", cities); mockLocationsManager.ExpectAndReturn("UpdateCity", true, city); LocationsManager mocklocationManager = (LocationsManager)mockLocationsManager.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); Assert.AreEqual("Pekin", locationService.GetCities()[0].Name); Assert.AreEqual(true, locationService.UpdateCity(city)); }
private void SetUpCurrentVersion(long version, bool assertRollbackIsCalled, bool includeBad) { DynamicMock providerMock = new DynamicMock(typeof(ITransformationProvider)); List<long> appliedVersions = new List<long>(); for (long i = 1; i <= version; i++) { appliedVersions.Add(i); } providerMock.SetReturnValue("get_AppliedMigrations", appliedVersions); providerMock.SetReturnValue("get_Logger", new Logger(false)); if (assertRollbackIsCalled) providerMock.Expect("Rollback"); else providerMock.ExpectNoCall("Rollback"); migrator = new Migrator((ITransformationProvider)providerMock.MockInstance, false, Assembly.GetExecutingAssembly()); // Enlève toutes les migrations trouvée automatiquement migrator.MigrationsTypes.Clear(); UpCalled.Clear(); DownCalled.Clear(); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(FirstMigration))); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(SecondMigration))); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(ThirdMigration))); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(ForthMigration))); migrator.MigrationsTypes.Add(new MigrationInfo(typeof(SixthMigration))); if (includeBad) { migrator.MigrationsTypes.Add(new MigrationInfo(typeof(BadMigration))); } }
public void TestUpdateDistrict() { Province provinceOne = new Province(2, "Pekin"); District district = new District("Pekin", provinceOne); List<District> districts = new List<District> {district}; DynamicMock mockLocationsManager = new DynamicMock(typeof (LocationsManager)); mockLocationsManager.SetReturnValue("GetDistricts", districts); mockLocationsManager.ExpectAndReturn("UpdateDistrict", true, district); LocationsManager mocklocationManager = (LocationsManager) mockLocationsManager.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); Assert.AreEqual("Pekin", locationService.GetDistricts()[0].Name); Assert.AreEqual(true, locationService.UpdateDistrict(district)); }
public void TestUpdateProvince() { Province provinceOne = new Province(2, "Pekin"); List<Province> provinces = new List<Province> {provinceOne}; DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager)); mockLocationsManager.SetReturnValue("GetProvinces", provinces); mockLocationsManager.ExpectAndReturn("UpdateProvince", true, provinceOne); LocationsManager mocklocationManager = (LocationsManager)mockLocationsManager.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); Assert.AreEqual("Pekin", locationService.GetProvinces()[0].Name); Assert.AreEqual(true, locationService.UpdateProvince(provinceOne)); }
public void SimpleFilters_And_RangeFilter_Return_SolrQuery_WithRangeQuery() { var selectedFilters = new List<SelectedFilter> { new SelectedFilter("sl1", "val1", true, 1), new SelectedFilter("sl2", "val2", true, 1), new SelectedFilter("sl3", "from-to", true, 1) }; var searchParameterMock = new DynamicMock(typeof(ISearchParameters<Publication>)); searchParameterMock.SetReturnValue("get_SelectedFilters", selectedFilters); var solrQueryBuilder = new SolrQueryBuilder<Publication>((ISearchParameters<Publication>)searchParameterMock.MockInstance); var query = solrQueryBuilder.BuildQuery(); Assert.IsTrue(query.Query == "publication_state_id:Active AND publication_visible:true AND sl1:val1 AND sl2:val2 AND sl3:[from TO to]"); }
public void FindAllEconomicActivitiesWhenResult() { _dynamicMock = new DynamicMock(typeof(EconomicActivityManager)); EconomicActivity activityA1 = new EconomicActivity { Id = 3, Name = "ServicesA1" }; EconomicActivity activityB2 = new EconomicActivity { Id = 4, Name = "ServicesB2" }; EconomicActivity activityA = new EconomicActivity { Id = 1,Name = "ServicesA", Parent = null ,Childrens = new List<EconomicActivity>{activityA1,activityB2}}; EconomicActivity activityB = new EconomicActivity { Id = 2, Name = "ServicesB", Parent = null }; List<EconomicActivity> activities = new List<EconomicActivity> {activityA, activityB}; _dynamicMock.SetReturnValue("SelectAllEconomicActivities", activities); _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance; _economicActivityServices = new EconomicActivityServices(_economicActivityManager); Assert.AreEqual(2, _economicActivityServices.FindAllEconomicActivities().Count); }
public void TestDeleteDistrictWithCityIn() { List<City> cities = _GetCities(); DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager)); dynamicMock.SetReturnValue("GetCities", cities); dynamicMock.Expect("DeleteDistrictById", 2); LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance; LocationServices locationService = new LocationServices(mocklocationManager); Assert.AreEqual(false, locationService.DeleteDistrict(2)); }