コード例 #1
0
        public void EventTests()
        {
            Customer temp = repository.GetCustomer("O1");
            DateTime now  = DateTime.Now;
            Event    b    = new BuyingEvent("b1", repository.GetState(), temp, now);

            repository.AddEvent(b);
            Assert.AreEqual(repository.GetAllEventsNumber(), 1);
        }
コード例 #2
0
ファイル: DataRepositoryTest.cs プロジェクト: 224086/ArtPa
        public void EventTestsDeleteException()
        {
            Client   temp = repository.GetClient("1");
            DateTime now  = DateTime.Now;
            Event    b    = new BuyingEvent("b1", repository.GetState(), temp, now);

            repository.AddEvent(b);
            Assert.AreEqual(repository.GetAllEventsNumber(), 1);
            repository.DeleteEvent("chlep");
        }
コード例 #3
0
        public void EventCorrectDeleteTests()
        {
            Client   temp = service.GetClientById("1");
            DateTime now  = DateTime.Now;
            Event    b    = new BuyingEvent("b1", service.GetState(), temp, now);

            service.AddEvent(b);
            Assert.AreEqual(service.GetAllEventsNumber(), 1);
            service.DeleteEvent("b1");
            Assert.AreEqual(service.GetAllEventsNumber(), 0);
        }
コード例 #4
0
ファイル: DataService.cs プロジェクト: kiimchi/zustyna
        public void BuyDonut(string customerid, int donutid, DateTime dayOfBuying, int amountOfDonuts)
        {
            Customer client     = repository.GetCustomer(customerid);
            Donut    donut      = repository.GetDonut(donutid);
            int      amountLeft = GetStateOfDonut(donutid) - amountOfDonuts;

            if (GetStateOfDonut(donutid) < amountOfDonuts)
            {
                throw new InvalidOperationException("There is not enough donuts in the shop.");
            }

            BuyingEvent buyEvent = new BuyingEvent(customerid, repository.GetState(), client, dayOfBuying);

            repository.AddEvent(buyEvent);
            UpdateDonutStateInfo(donutid, amountLeft);
        }
コード例 #5
0
ファイル: DataService.cs プロジェクト: 224086/ArtPa
        public void BuyBaking(string customerId, int bakingId, DateTime dayOfBuying, int amount)
        {
            Client client     = repository.GetClient(customerId);
            Baking baking     = repository.GetBaking(bakingId);
            int    amountLeft = GetStateOfBaking(bakingId) - amount;

            if (GetStateOfBaking(bakingId) < amount)
            {
                throw new InvalidOperationException("There is not enough bakings in the shop.");
            }

            BuyingEvent buyEvent = new BuyingEvent(customerId, repository.GetState(), client, dayOfBuying);

            repository.AddEvent(buyEvent);
            UpdateBakingStateInfo(bakingId, amountLeft);
        }