Example #1
0
        public void GetById_hasThreeCartsInDB_returnReturnOnlyCartWithCorrectId()
        {
            var target = new FakeShoppingCartRepository(_databaseSettings);

            var cart1 = new CartBuilder().WithId(null).WithCustomerId("1").Build();

            target.Create(cart1);

            var cart2 = new CartBuilder().WithId(null).WithCustomerId("2").Build();

            target.Create(cart2);

            var cart3 = new CartBuilder().WithId(null).WithCustomerId("3").Build();

            target.Create(cart3);

            var actual = target.FindById(cart2.Id);

            Assert.Equal(cart2, actual);
        }
Example #2
0
        public void FindAll_HasTwoCartsInDB_ReturnAllCarts()
        {
            var target = new FakeShoppingCartRepository(_databaseSettings);

            var cart1 = new CartBuilder().WithId(null).WithCustomerId("1").Build();

            target.Create(cart1);

            var cart2 = new CartBuilder().WithId(null).WithCustomerId("2").Build();

            target.Create(cart2);

            var actual = target.FindAll().ToList();

            var expected = new List <Cart> {
                cart1, cart2
            };

            Assert.Equal(expected, actual);
        }
Example #3
0
        public void GetById_CartNotFound_ReturnNull()
        {
            var target = new FakeShoppingCartRepository(_databaseSettings);

            var cart1 = new CartBuilder().WithId(null).WithCustomerId("1").Build();

            target.Create(cart1);

            var cart2 = new CartBuilder().WithId(null).WithCustomerId("2").Build();

            target.Create(cart2);


            var cart3 = new CartBuilder().WithId(null).WithCustomerId("3").Build();

            target.Create(cart3);

            var actual = target.FindById(Invalid_ID);

            Assert.Null(actual);
        }
Example #4
0
        public void RemoveById_CartFound_RemoveFromDb()
        {
            var target = new FakeShoppingCartRepository(_databaseSettings);
            var cart1  = new CartBuilder().WithId(null).WithCustomerId("1").Build();

            target.Create(cart1);

            target.Remove(cart1.Id);

            var result = target.FindById(cart1.Id);

            Assert.Null(result);
        }
Example #5
0
        public void Update_CartFound_UpdateValue()
        {
            var target = new FakeShoppingCartRepository(_databaseSettings);
            var cart1  = new CartBuilder().WithId(null).WithCustomerId("1").Build();

            target.Create(cart1);
            cart1.CustomerId = "other";

            target.Update(cart1.Id, cart1);

            var result = target.FindById(cart1.Id);

            Assert.Equal("other", cart1.CustomerId);
        }