상속: IStateService
예제 #1
0
        public void GetFinalStatesIdsTest()
        {
            Mock<IStateRepository> fakeStateRepo = new Mock<IStateRepository>();
            Mock<IStateWorkflowRepository> fakeStateWorkflowRepo = new Mock<IStateWorkflowRepository>();
            var stateService = new StateService(fakeStateRepo.Object, fakeStateWorkflowRepo.Object);

            var openStateId = Guid.NewGuid();
            var closedStateId = Guid.NewGuid();
            List<State> states = new List<State>()
            {
                new State {Title = "Open", Colour = "black", IsInitial = true, OrderIndex = 1, Id = openStateId},
                new State {Title = "Closed", Colour = "white", IsInitial = false, OrderIndex = 2, Id = closedStateId}
            };

            List<StateWorkflow> workflows = new List<StateWorkflow>()
            {
                new StateWorkflow {FromStateId = openStateId, ToStateId = closedStateId }
            };

            fakeStateRepo.Setup(i => i.Fetch()).Returns(states.AsQueryable());
            fakeStateWorkflowRepo.Setup(i => i.Fetch()).Returns(workflows.AsQueryable());

            var actual = stateService.GetFinalStateIds();

            Assert.AreEqual(actual.FirstOrDefault(), closedStateId);
        }
예제 #2
0
        public void GetInitialStatesTest()
        {
            Mock<IStateRepository> fakeStateRepo = new Mock<IStateRepository>();
            Mock<IStateWorkflowRepository> fakeStateWorkflowRepo = new Mock<IStateWorkflowRepository>();
            var stateService = new StateService(fakeStateRepo.Object, fakeStateWorkflowRepo.Object);

            var openStateId = Guid.NewGuid();
            var closedStateId = Guid.NewGuid();
            List<State> states = new List<State>()
            {
                new State {Title = "Open", Colour = "black", IsInitial = true, OrderIndex = 1, Id = openStateId},
                new State {Title = "Closed", Colour = "white", IsInitial = false, OrderIndex = 2, Id = closedStateId}
            };

            fakeStateRepo.Setup(i => i.FindBy(It.IsAny<Expression<Func<State, bool>>>()))
                .Returns((Expression<Func<State, bool>> expression) => states.AsQueryable().Where(expression));

            var actual = stateService.GetInitialStates();

            Assert.AreEqual(actual.First().Id, openStateId);
        }