예제 #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
        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
        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);
        }