public void GetAllServicePlanes()
        {
            var mock = new Mock <IRepository <ServicePlan> >();

            mock.Setup(repo => repo.GetAll()).Returns(GetAllTest());
            var factoryMock = new Mock <IRepositoryFactory>();

            factoryMock.Setup(f => f.GetRepository <ServicePlan>()).Returns(mock.Object);
            _servicePlanController = new ServicePlanController(factoryMock.Object);

            var json        = _servicePlanController.GetAll();
            var servicePlan = json.Value as List <ServicePlan>;

            Assert.NotNull(json);
            Assert.NotNull(servicePlan);
            Assert.AreEqual(servicePlan.Count, 2);

            //var mock1 = new Mock<IRepository<ServicePlan>>();
            //mock1.Setup(repo => repo.GetAll().FirstOrDefault()).Returns(GetFirstOrDefaultTest(1));
            //var factoryMock1 = new Mock<IRepositoryFactory>();
            //factoryMock1.Setup(f => f.GetRepository<ServicePlan>()).Returns(mock1.Object);
            //_servicePlanController = new ServicePlanController(factoryMock1.Object);

            //json = _servicePlanController.GetAll();
            //servicePlan = json.Value as List<ServicePlan>;
            //Assert.AreEqual();
        }
        public void Create()
        {
            var         memoryStore     = new List <ServicePlan>();
            ServicePlan servicePlanStub = new ServicePlan {
                Id = 1
            };
            var mock = new Mock <IRepository <ServicePlan> >();

            mock.Setup(repo => repo.GetAll()).Returns(memoryStore.AsQueryable());
            mock.Setup(repo => repo.Create(It.IsAny <ServicePlan>())).Returns((ServicePlan servicePlan) => {
                servicePlan.Id = 1;
                memoryStore.Add(servicePlan);
                return(servicePlan);
            });
            var factoryMock = new Mock <IRepositoryFactory>();

            factoryMock.Setup(f => f.GetRepository <ServicePlan>()).Returns(mock.Object);
            _servicePlanController = new ServicePlanController(factoryMock.Object);
            var emptyJson = _servicePlanController.GetAll();

            Assert.IsNotNull(emptyJson);
            var emptyStore = emptyJson.Value as List <ServicePlan>;

            Assert.IsNotNull(emptyStore);
            Assert.AreEqual(emptyStore.Count, 0);
            var json = _servicePlanController.Create(servicePlanStub);

            Assert.IsNotNull(json);
            var result = json.Value as ServicePlan;

            Assert.NotNull(result);
            Assert.AreEqual(result.Id, 1);
            Assert.AreEqual(result.ServicePlanName, servicePlanStub.ServicePlanName);
            var notEmptyJson = _servicePlanController.GetAll();

            Assert.IsNotNull(notEmptyJson);
            var notEmptyStore = notEmptyJson.Value as List <ServicePlan>;

            Assert.IsNotNull(notEmptyStore);
            Assert.AreEqual(notEmptyStore.Count, 1);
        }