Exemple #1
0
        public void Units_setting()
        {
            var fakeOrderItem = new OrderItem(
                productId: 1,
                productName: "FakeProductName",
                unitPrice: 23.22m,
                discount: 100.2m,
                PictureUrl: "FakePictureUrl",
                units: 10);

            Assert.Throws <OrderingDomainException>(() => { fakeOrderItem.AddUnits(-1); });

            fakeOrderItem.AddUnits(10);
            Assert.Equal <int>(fakeOrderItem.GetUnits(), 20);
        }
        public void OrderItem_Invalid_Units_Setting()
        {
            //Arrange
            var       productId     = Guid.NewGuid();
            var       productName   = "A";
            const int unitPrice     = 12;
            var       fakeOrderItem = new OrderItem(Guid.NewGuid(), productId, unitPrice, _pricingStrategy);


            //Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => fakeOrderItem.AddUnits(-1));
        }
Exemple #3
0
        public void Invalid_units_setting()
        {
            // Arrange
            var productId   = 1;
            var productName = "FakeProductName";
            var unitPrice   = 12;
            var discount    = 15;
            var pictureUrl  = "FakeUrl";
            var units       = 5;

            // Act
            var fakeOrderItem = new OrderItem(productId, productName, unitPrice, discount, pictureUrl, units);

            // Assert
            Assert.Throws <OrderingDomainException>(() => fakeOrderItem.AddUnits(-1));
        }
        public void OrderItem_AddUnits_UpdatesUnits()
        {
            //Arrange
            var       productId     = Guid.NewGuid();
            var       productName   = "A";
            const int unitPrice     = 12;
            var       fakeOrderItem = new OrderItem(Guid.NewGuid(), productId, unitPrice, _pricingStrategy);


            //Act
            fakeOrderItem.AddUnits(1);

            const int expectedUnits = 2;


            //Assert
            Assert.Equal(expectedUnits, fakeOrderItem.GetUnits());
        }