public void DeleteEventTest() { DataRepository dataRepository = new DataRepository(new AutoFillFull()); Assert.AreEqual(dataRepository.GetAllEvents().Count, 3); Product product = new Product { Id = Guid.NewGuid(), Name = "TestName", Description = "TestDescription" }; Client client = new Client { Id = Guid.NewGuid(), Birthday = new DateTime(), Email = "*****@*****.**", LastName = "LastName", Name = "Name" }; Event sellEvent = new SellEvent(new Guid(), client, new ItemStatus(product, 10f, 10f, 10), "example"); dataRepository.AddEvent(sellEvent); Assert.AreEqual(dataRepository.GetAllEvents().Count, 4); dataRepository.DeleteEvent(sellEvent); Assert.AreEqual(dataRepository.GetAllEvents().Count, 3); Assert.IsFalse(dataRepository.GetAllEvents().Contains(sellEvent)); // rozwiazanie ze strony msdn https://docs.microsoft.com/pl-pl/visualstudio/test/walkthrough-creating-and-running-unit-tests-for-managed-code?view=vs-2019 Assert.ThrowsException <ArgumentException>(() => dataRepository.DeleteEvent(sellEvent)); }
public void AutoFill(DataContext dataContext) { List <Client> clients = dataContext.Clients; Dictionary <Guid, Product> products = dataContext.Products; ObservableCollection <Event> events = dataContext.Events; List <Status> statuses = dataContext.Statuses; Client client1 = new Client { Id = Guid.NewGuid(), Name = Rand.GetRandString(), LastName = Rand.GetRandString(), Birthday = new DateTime(1000, 1, 1), Email = Rand.GetRandString() + "@example.com" }; Client client2 = new Client { Id = Guid.NewGuid(), Name = Rand.GetRandString(), LastName = Rand.GetRandString(), Birthday = new DateTime(2000, 2, 2), Email = Rand.GetRandString() + "@example.com" }; Product product1 = new Product { Id = Guid.NewGuid(), Name = Rand.GetRandString(), Description = Rand.GetRandString() }; Product product2 = new Product { Id = Guid.NewGuid(), Name = Rand.GetRandString(), Description = Rand.GetRandString() }; ItemStatus itemStatus = new ItemStatus(product1, 1.1f, 1.1f, 1); ItemStatus itemStatus1 = new ItemStatus(product2, 1.1f, 1.1f, 1); ItemStatus itemStatus2 = new ItemStatus(product1, 11.1f, 11.1f, 11); ItemStatus itemStatus3 = new ItemStatus(product2, 11.1f, 11.1f, 11); Event event1 = new BuyEvent(new Guid(), client1, itemStatus, "buy example"); Event event2 = new SellEvent(new Guid(), client2, itemStatus1, "sell example"); products.Add(product1.Id, product1); products.Add(product2.Id, product2); clients.Add(client1); clients.Add(client2); events.Add(event1); events.Add(event2); statuses.Add(itemStatus2); statuses.Add(itemStatus3); }
void AddEvent(Client client, Status status, string description, Type type) { Event eventToAdd; if (type == typeof(DestroyEvent)) { eventToAdd = new DestroyEvent(new Guid(), client, status, description); _dataRepository.AddEvent(eventToAdd); } else if (type == typeof(SellEvent)) { eventToAdd = new SellEvent(new Guid(), client, status, description); _dataRepository.AddEvent(eventToAdd); } else if (type == typeof(BuyEvent)) { eventToAdd = new BuyEvent(new Guid(), client, status, description); _dataRepository.AddEvent(eventToAdd); } }
public void UpdateEventTest() { DataRepository dataRepository = new DataRepository(new AutoFillFull()); Assert.AreEqual(dataRepository.GetAllEvents().Count, 3); Product product = new Product { Id = Guid.NewGuid(), Name = "TestName", Description = "TestDescription" }; Client client = new Client { Id = Guid.NewGuid(), Birthday = new DateTime(), Email = "*****@*****.**", LastName = "LastName", Name = "Name" }; Event sellEvent = new SellEvent(new Guid(), client, new ItemStatus(product, 10f, 10f, 10), "example"); Assert.IsFalse(dataRepository.GetAllEvents().Contains(sellEvent)); dataRepository.AddEvent(sellEvent); Assert.IsTrue(dataRepository.GetAllEvents().Contains(sellEvent)); sellEvent.Status = new ItemStatus(product, 10f, 10f, 100); dataRepository.UpdateEvent(sellEvent); Assert.IsTrue(dataRepository.GetAllEvents().Contains(sellEvent)); Assert.ThrowsException <ArgumentException>(() => dataRepository.UpdateEvent(new SellEvent( Guid.NewGuid(), client, new ItemStatus(product, 10f, 10f, 10), "example" ))); }
public void OnSellMethod(GameObject Tile) { SellEvent?.Invoke(Tile); }
void IAutoFiller.AutoFill(DataContext dataContext) { List <Client> clients = dataContext.Clients; Dictionary <Guid, Product> products = dataContext.Products; ObservableCollection <Event> events = dataContext.Events; List <Status> statuses = dataContext.Statuses; Client client1 = new Client { Id = Guid.NewGuid(), Name = "Name1", LastName = "LastName1", Birthday = new DateTime(1000, 1, 1), Email = "*****@*****.**" }; Client client2 = new Client { Id = Guid.NewGuid(), Name = "Name2", LastName = "LastName2", Birthday = new DateTime(2000, 2, 2), Email = "*****@*****.**" }; Product product1 = new Product { Id = Guid.NewGuid(), Name = "Product1", Description = "Description1" }; Product product2 = new Product { Id = Guid.NewGuid(), Name = "Product2", Description = "Description2" }; ItemStatus itemStatus = new ItemStatus(product1, 1.1f, 1.1f, 1); ItemStatus itemStatus1 = new ItemStatus(product2, 1.1f, 1.1f, 1); ItemStatus itemStatus2 = new ItemStatus(product1, 11.1f, 11.1f, 11); ItemStatus itemStatus3 = new ItemStatus(product2, 11.1f, 11.1f, 11); Event event1 = new DestroyEvent(Guid.NewGuid(), client1, itemStatus, "example destroy"); Event event2 = new BuyEvent(Guid.NewGuid(), client1, itemStatus1, "example buy"); Event event3 = new SellEvent(Guid.NewGuid(), client2, itemStatus1, "example sell"); products.Add(product1.Id, product1); products.Add(product2.Id, product2); clients.Add(client1); clients.Add(client2); events.Add(event1); events.Add(event2); events.Add(event3); statuses.Add(itemStatus2); statuses.Add(itemStatus3); }