コード例 #1
0
        void IGiftcardProductService.CreateGiftcard(string name, int price, bool isPriceOverrideable)
        {
            var giftcard = new GiftcardProduct(name, price);

            giftcard.SetPriceOverrideAble(isPriceOverrideable);

            _giftcardProductRepository.Insert(giftcard);
        }
コード例 #2
0
        public void IsPriceOverrideable_Should_Default_False()
        {
            //Arrange
            var product = new GiftcardProduct("TestItem", 1000);

            //Act

            //Assert
            Assert.False(product.IsPriceOverrideable);
        }
コード例 #3
0
 public static GiftcardProductDto Map(this GiftcardProduct giftcardProduct)
 {
     return(new GiftcardProductDto
     {
         Id = giftcardProduct.Id,
         IsPriceOverrideable = giftcardProduct.IsPriceOverrideable,
         Name = giftcardProduct.Name,
         Price = giftcardProduct.Price,
     });
 }
コード例 #4
0
        public void Update_Description()
        {
            //Arrange
            var product = new GiftcardProduct("SomeName", "SomeDescription", 1000);

            //Act
            product.UpdateDescription("Description");

            //Assert
            Assert.Equal("Description", product.Description);
        }
コード例 #5
0
        public void Update_Name()
        {
            //Arrange
            var product = new GiftcardProduct("SomeName", 1000);

            //Act
            product.UpdateName("NewName");

            //Assert
            Assert.Equal("NewName", product.Name);
        }
コード例 #6
0
        public void Set_PriceOverrideable_True()
        {
            //Arrange
            var giftcardProduct = new GiftcardProduct("Test Item", 100);

            //Act
            giftcardProduct.SetPriceOverrideAble(true);

            //Assert
            Assert.True(giftcardProduct.IsPriceOverrideable);
        }
コード例 #7
0
        public void Be_Created_With_Name_And_Price()
        {
            //Arrange
            const string Name  = "SomeName";
            const int    Price = 1000;

            //Act
            var giftCardProduct = new GiftcardProduct(Name, Price);

            //Assert
            Assert.Equal(Name, giftCardProduct.Name);
            Assert.Equal(Price, giftCardProduct.Price);
        }
コード例 #8
0
        public void AddOrderLine()
        {
            //Arrange
            var sut       = new Order();
            var product   = new GiftcardProduct("MyTestGiftcardProduct", 1000);
            var orderLine = new OrderLine(1, product);

            //Act
            sut.AddOrderLine(orderLine);

            //Assert
            Assert.Equal(1, sut.OrderLineCount);
        }
コード例 #9
0
        public GiftCardOrderLine(GiftcardProduct giftcard, int amount, string message, string from, string to) : base(amount, giftcard)
        {
            if (string.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentException("Message must contain something", nameof(message));
            }
            if (string.IsNullOrWhiteSpace(from))
            {
                throw new ArgumentException("There has to be a sender", nameof(from));
            }
            if (string.IsNullOrWhiteSpace(to))
            {
                throw new ArgumentException("There has to be a receiver", nameof(to));
            }

            Message = message;
            From    = from;
            To      = to;
        }
コード例 #10
0
        void IGiftcardProductService.CreateGiftcard(string name, int price)
        {
            var giftcard = new GiftcardProduct(name, price);

            _giftcardProductRepository.Insert(giftcard);
        }
コード例 #11
0
 void IBaseRepository <GiftcardProduct> .Update(GiftcardProduct entity)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
        async Task <GiftcardProduct> IBaseRepository <GiftcardProduct> .Get(int id)
        {
            var item = new GiftcardProduct("Something", 10);

            return(item);
        }