public void given_customer_when_deleted_verify_customer_is_deleted()
        {
            _manager.Setup(x => x.DeleteCustomer(It.IsAny <int>())).Returns(1);

            var result = _controller.Delete(CustomerAcctDetailsParam.GetSingle(0).CustomerId);

            Assert.Equal(1, result);
        }
        public void given_new_customer_when_created_then_verify_customer_created(int input1)
        {
            CustomerAcctDetails custDetails = CustomerAcctDetailsParam.GetSingle(input1); // new Fixture().Create<CustomerAcctDetails>();

            _manager.Setup(x => x.AddCustomer(It.IsAny <CustomerAcctDetails>())).Returns(1);

            var result = _controller.Create(custDetails);

            Assert.Equal(1, result);
        }
        public void given_customer_id_when_fetched_then_returns_customer_details(int input1)
        {
            CustomerAcctDetails custDetails = CustomerAcctDetailsParam.GetSingle(input1); // new Fixture().Create<CustomerAcctDetails>();

            _manager.Setup(x => x.GetCustomerData(custDetails.CustomerId)).Returns(custDetails);

            var result = _controller.Details(custDetails.CustomerId);

            Assert.NotNull(result);
            Assert.Equal(custDetails, result);
        }
        public void given_customer_when_added_then_customer_gets_created(int input1)
        {
            var input = CustomerAcctDetailsParam.GetSingle(input1);

            _dbContext.Setup(db => db.CustomerAcctDetails.Add(input));

            var result = _dataAccess.AddCustomer(input);

            Assert.Equal(1, result);
            _dbContext.Verify(x => x.SaveChanges(), Times.Once());
        }
        public void given_customer_when_updated_then_verify_the_changes(int input1)
        {
            CustomerAcctDetails custDetails = CustomerAcctDetailsParam.GetSingle(input1);

            custDetails.PhoneNumber = "04425984656";

            _manager.Setup(x => x.UpdateCustomer(custDetails)).Returns(1);

            var result = _controller.Edit(custDetails);

            Assert.Equal(1, result);
        }
        public void given_customer_id_when_deleted_verify_customer_is_deleted(int input1)
        {
            var data = CustomerAcctDetailsParam.GetSingle(input1);

            _dbContext.Setup(db => db.CustomerAcctDetails.Find(input1)).Returns(data);
            _dbContext.Setup(db => db.CustomerAcctDetails.Remove(data));

            var result = _dataAccess.DeleteCustomer(input1);

            Assert.Equal(1, result);
            _dbContext.Verify(x => x.SaveChanges(), Times.Once());
        }
        public void given_customer_id_when_retrieved_returns_customer_details(int input1)
        {
            var data = CustomerAcctDetailsParam.GetSingle(input1);

            _dbContext.Setup(db => db.CustomerAcctDetails.Find(input1)).Returns(data);

            var result = _dataAccess.GetCustomerData(input1);

            Assert.NotNull(result);
            Assert.IsType(data.GetType(), result);
            Assert.Equal(input1, result.CustomerId);
        }
        public void given_a_customer_when_edited_then_updates_customer(int input1)
        {
            var input = CustomerAcctDetailsParam.GetSingle(input1);

            var expected = new FakeDbSet <CustomerAcctDetails>()
            {
                CustomerAcctDetailsParam.GetSingle(input1)
            };

            //_dbContext.Setup(db => db.CustomerAcctDetails).Returns(expected);
            _dbContext.Setup(x => x.Entry(input)).Returns(() => _dbContext.Object.Entry(input)).Callback(() => _dbContext.Setup(db => db.CustomerAcctDetails).Returns(expected));

            var result = _dataAccess.UpdateCustomer(input);
        }
        public void given_customers_when_retrived_customers_returned(int input1, int input2)
        {
            //var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var expected = new FakeDbSet <CustomerAcctDetails>()
            {
                CustomerAcctDetailsParam.GetSingle(input1), CustomerAcctDetailsParam.GetSingle(input2)
            };

            _dbContext.Setup(db => db.CustomerAcctDetails).Returns(expected);

            var result = _dataAccess.GetAllCustomers();

            Assert.NotNull(result);
            Assert.True(result.Count() > 0);
            Assert.Equal(expected.FirstOrDefault(c => c.CustomerId == input1).Status, result.FirstOrDefault(c => c.CustomerId == input1).Status);
            Assert.Equal(expected.FirstOrDefault(c => c.CustomerId == input1).UpdatedBy, result.FirstOrDefault(c => c.CustomerId == input1).UpdatedBy);
        }