public void Should_PublishAndApplyEvent_NonGeneric() { // Arrange var serializationStrategy = new JsonEventSerializationStrategy(); // if you want to use real database like mongo, use next two lines to configure and then use it to configure event store // var mongoAggregateEventsRepository = new MongoRepository<AggregateEvent>("mongodb://localhost", "DDD_Light_Tests_EventStore", "EventStore"); // mongoAggregateEventsRepository.DeleteAll(); var inMemoryAggregateEventsRepository = new InMemoryRepository <Guid, AggregateEvent>(); inMemoryAggregateEventsRepository.DeleteAll(); EventStore.EventStore.Instance.Configure(inMemoryAggregateEventsRepository, serializationStrategy); EventBus.Instance.Configure(EventStore.EventStore.Instance, serializationStrategy, false); Func <Type, object> getInstance = type => { if (type == typeof(SomeAggregateRootCreatedHandler)) { return(new SomeAggregateRootCreatedHandler()); } if (type == typeof(MockHandler)) { return(new MockHandler()); } if (type == typeof(IRepository <Guid, SomeAggregateRoot>)) { return(new InMemoryRepository <Guid, SomeAggregateRoot>()); } throw new Exception("type " + type.ToString() + " could not be resolved"); }; HandlerSubscribtions.SubscribeAllHandlers(getInstance); AggregateCache.AggregateCache.Instance.Configure(EventStore.EventStore.Instance, getInstance); AggregateBus.InProcess.AggregateBus.Instance.Configure(EventBus.Instance, AggregateCache.AggregateCache.Instance); const string createdMessage = "hello, I am created!"; var id = Guid.NewGuid(); // Act var ar = new SomeAggregateRoot(id, createdMessage); // Assert Assert.AreEqual(1, EventStore.EventStore.Instance.Count()); Assert.AreEqual(typeof(SomeAggregateRootCreated), Type.GetType(EventStore.EventStore.Instance.GetAll().First().EventType)); Assert.AreEqual(createdMessage, ((SomeAggregateRootCreated)serializationStrategy.DeserializeEvent(EventStore.EventStore.Instance.GetAll().First().SerializedEvent, typeof(SomeAggregateRootCreated))).Message); }
public void Setup() { NetworkRepository = new InMemoryRepository <TaxiHailNetworkSettings>(); CompanyRepository = new InMemoryRepository <Company>(); Sut = new RoamingApiController(NetworkRepository, CompanyRepository, GetMockedMarketRepo()); _chrisTaxi = new TaxiHailNetworkSettings { Id = "ChrisTaxi", IsInNetwork = true, Market = "MTL", FleetId = 424242, WhiteListedFleetIds = "987564,321674,23134,88784,99999", // ChrisBis, Tom, Tony, Pilou, Last. Bob exclued Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxiBis", CanAccept = true, CanDispatch = true, Order = 2 }, new CompanyPreference { CompanyKey = "TomTaxi", CanAccept = true, CanDispatch = false, Order = 0 }, new CompanyPreference { CompanyKey = "PilouTaxi", CanAccept = true, CanDispatch = true, Order = 1 } } }; _chrisTaxiBis = new TaxiHailNetworkSettings { Id = "ChrisTaxiBis", IsInNetwork = true, Market = "MTL", FleetId = 987564, Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxi", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "TomTaxi", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "PilouTaxi", CanAccept = true, CanDispatch = true }, } }; _tonyTaxi = new TaxiHailNetworkSettings { Id = "TonyTaxi", IsInNetwork = true, Market = "CHI", FleetId = 321674 }; _tomTaxi = new TaxiHailNetworkSettings { //same Longitude as TonyTaxi Id = "TomTaxi", Market = "CHI", FleetId = 23134, IsInNetwork = true, Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxiBis", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "ChrisTaxi", CanAccept = false, CanDispatch = true }, new CompanyPreference { CompanyKey = "PilouTaxi", CanAccept = true, CanDispatch = true }, } }; _pilouTaxi = new TaxiHailNetworkSettings { //Same Latitude as ChrisTaxi and Chris TaxiBis Id = "PilouTaxi", IsInNetwork = true, Market = "NYC", FleetId = 88784, WhiteListedFleetIds = "444444", // Random one to test BobTaxi exclusion Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxiBis", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "ChrisTaxi", CanAccept = false, CanDispatch = true }, new CompanyPreference { CompanyKey = "TomTaxi", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "BobTaxi", CanAccept = true, CanDispatch = true }, } }; _lastTaxi = new TaxiHailNetworkSettings { //Overlap ChrisTaxi and ChrisTaxiBis Id = "LastTaxi", IsInNetwork = true, Market = "SYD", FleetId = 99999, BlackListedFleetIds = "10101019, 666, 010101" }; _bobTaxi = new TaxiHailNetworkSettings { Id = "BobTaxi", IsInNetwork = true, Market = "NYC", FleetId = 587564, Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxi", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "TomTaxi", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "PilouTaxi", CanAccept = true, CanDispatch = true } } }; _taxiWhenBlacklistedProhibited = new TaxiHailNetworkSettings { Id = "TaxiWhenBlacklistedProhibited", IsInNetwork = true, Market = "SYD", FleetId = 88784, BlackListedFleetIds = "666", Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "BlacklistedTaxi", CanAccept = true, CanDispatch = true } } }; _blacklistedTaxi = new TaxiHailNetworkSettings() { Id = "BlacklistedTaxi", IsInNetwork = true, Market = "SYD", FleetId = 666, Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "TaxiWhenBlacklistedProhibited", CanAccept = true, CanDispatch = true } } }; _chrisTaxiCompany = new Company { Id = "ChrisTaxi", CompanyKey = "ChrisTaxi", CompanyName = "ChrisTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _chrisTaxiBisCompany = new Company { Id = "ChrisTaxiBis", CompanyKey = "ChrisTaxiBis", CompanyName = "ChrisTaxiBis", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://altavista.com" } }; _lastTaxiCompany = new Company { Id = "LastTaxi", CompanyKey = "LastTaxi", CompanyName = "LastTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _pilouTaxiCompany = new Company { Id = "PilouTaxi", CompanyKey = "PilouTaxi", CompanyName = "PilouTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _tomTaxiCompany = new Company { Id = "TomTaxi", CompanyKey = "TomTaxi", CompanyName = "TomTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _tonyTaxiCompany = new Company { Id = "TonyTaxi", CompanyKey = "TonyTaxi", CompanyName = "TonyTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _bobTaxiCompany = new Company { Id = "BobTaxi", CompanyKey = "BobTaxi", CompanyName = "BobTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://altavista.com" } }; _blacklistedTaxiCompany = new Company() { Id = "BlacklistedTaxi", CompanyKey = "BlacklistedTaxi", CompanyName = "BlacklistedTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _taxiWhenBlacklistedProhibitedCompany = new Company() { Id = "TaxiWhenBlacklistedProhibited", CompanyKey = "TaxiWhenBlacklistedProhibited", CompanyName = "TaxiWhenBlacklistedProhibited", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; NetworkRepository.DeleteAll(); NetworkRepository.Add(_chrisTaxi); NetworkRepository.Add(_chrisTaxiBis); NetworkRepository.Add(_tonyTaxi); NetworkRepository.Add(_tomTaxi); NetworkRepository.Add(_pilouTaxi); NetworkRepository.Add(_lastTaxi); NetworkRepository.Add(_bobTaxi); NetworkRepository.Add(_blacklistedTaxi); NetworkRepository.Add(_taxiWhenBlacklistedProhibited); CompanyRepository.DeleteAll(); CompanyRepository.Add(_chrisTaxiCompany); CompanyRepository.Add(_chrisTaxiBisCompany); CompanyRepository.Add(_tonyTaxiCompany); CompanyRepository.Add(_tomTaxiCompany); CompanyRepository.Add(_pilouTaxiCompany); CompanyRepository.Add(_lastTaxiCompany); CompanyRepository.Add(_bobTaxiCompany); CompanyRepository.Add(_blacklistedTaxiCompany); CompanyRepository.Add(_taxiWhenBlacklistedProhibitedCompany); }
public void Setup() { NetworkRepository = new InMemoryRepository <TaxiHailNetworkSettings>(); CompanyRepository = new InMemoryRepository <Company>(); Sut = new NetworkApiController(NetworkRepository, CompanyRepository, GetMockedMarketRepo()); _chrisTaxi = new TaxiHailNetworkSettings() { Id = "ChrisTaxi", IsInNetwork = true, Market = "MTL", WhiteListedFleetIds = "123456,564321", // And excluding PilouTaxi and TomTaxi Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxiBis", CanAccept = true, CanDispatch = true, Order = 2 }, new CompanyPreference { CompanyKey = "TomTaxi", CanAccept = true, CanDispatch = false, Order = 0 }, new CompanyPreference { CompanyKey = "PilouTaxi", CanAccept = true, CanDispatch = true, Order = 1 }, } }; _chrisTaxiBis = new TaxiHailNetworkSettings() { Id = "ChrisTaxiBis", IsInNetwork = true, Market = "MTL", FleetId = 123456, Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxi", CanAccept = false, CanDispatch = true }, new CompanyPreference { CompanyKey = "TomTaxi", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "PilouTaxi", CanAccept = true, CanDispatch = true }, } }; _tonyTaxi = new TaxiHailNetworkSettings() { Id = "TonyTaxi", IsInNetwork = true, Market = "CHI", FleetId = 564321 }; _tomTaxi = new TaxiHailNetworkSettings() { //same Longitude as TonyTaxi Id = "TomTaxi", Market = "CHI", IsInNetwork = true, FleetId = 99999, Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxiBis", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "ChrisTaxi", CanAccept = false, CanDispatch = true }, new CompanyPreference { CompanyKey = "PilouTaxi", CanAccept = true, CanDispatch = true }, } }; _pilouTaxi = new TaxiHailNetworkSettings() { //Same Latitude as ChrisTaxi and Chris TaxiBis Id = "PilouTaxi", IsInNetwork = true, Market = "NYC", FleetId = 44444, Preferences = new List <CompanyPreference> { new CompanyPreference { CompanyKey = "ChrisTaxiBis", CanAccept = true, CanDispatch = true }, new CompanyPreference { CompanyKey = "ChrisTaxi", CanAccept = false, CanDispatch = true }, new CompanyPreference { CompanyKey = "TomTaxi", CanAccept = true, CanDispatch = true }, } }; _lastTaxi = new TaxiHailNetworkSettings() { //Overlap ChrisTaxi and ChrisTaxiBis Id = "LastTaxi", IsInNetwork = true, Market = "SYD", BlackListedFleetIds = "10101019, 666, 010101" }; _blacklistedTaxi = new TaxiHailNetworkSettings() { Id = "TaxiBlacklisted", IsInNetwork = true, Market = "SYD", FleetId = 666 }; _chrisTaxiCompany = new Company() { Id = "ChrisTaxi", CompanyKey = "ChrisTaxi", CompanyName = "ChrisTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _chrisTaxiBisCompany = new Company() { Id = "ChrisTaxiBis", CompanyKey = "ChrisTaxiBis", CompanyName = "ChrisTaxiBis", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _lastTaxiCompany = new Company() { Id = "LastTaxi", CompanyKey = "LastTaxi", CompanyName = "LastTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _pilouTaxiCompany = new Company() { Id = "PilouTaxi", CompanyKey = "PilouTaxi", CompanyName = "PilouTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _tomTaxiCompany = new Company() { Id = "TomTaxi", CompanyKey = "TomTaxi", CompanyName = "TomTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _tonyTaxiCompany = new Company() { Id = "TonyTaxi", CompanyKey = "TonyTaxi", CompanyName = "TonyTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; _blacklistedTaxiCompany = new Company() { Id = "BlacklistedTaxi", CompanyKey = "BlacklistedTaxi", CompanyName = "BlacklistedTaxi", IBS = new IBSSettings { Password = "******", Username = "******", ServiceUrl = "http://google.com" } }; NetworkRepository.DeleteAll(); NetworkRepository.Add(_chrisTaxi); NetworkRepository.Add(_chrisTaxiBis); NetworkRepository.Add(_tonyTaxi); NetworkRepository.Add(_tomTaxi); NetworkRepository.Add(_pilouTaxi); NetworkRepository.Add(_lastTaxi); NetworkRepository.Add(_blacklistedTaxi); CompanyRepository.DeleteAll(); CompanyRepository.Add(_chrisTaxiCompany); CompanyRepository.Add(_chrisTaxiBisCompany); CompanyRepository.Add(_tonyTaxiCompany); CompanyRepository.Add(_tomTaxiCompany); CompanyRepository.Add(_pilouTaxiCompany); CompanyRepository.Add(_lastTaxiCompany); CompanyRepository.Add(_blacklistedTaxiCompany); }