Example #1
0
        public async Task VisitsController_UpdateStatus_Test()
        {
            bool called             = false;
            var  visitRepository    = new Data.Repositories.Fakes.StubIVisitRepository();
            var  employeeRepository = new Data.Repositories.Fakes.StubIEmployeeRepository();

            var visit = new Visit()
            {
                VisitId    = 1,
                Status     = VisitStatus.Pending,
                EmployeeId = 1,
            };

            visitRepository.GetCompleteInfoAsyncInt32PictureType = (id, visitPicture) =>
            {
                return(Task.FromResult(visit));
            };

            employeeRepository.GetCompleteInfoAsyncInt32PictureType = (id, pictureType) =>
            {
                Employee employee = null;
                if (id == visit.EmployeeId)
                {
                    employee = new Employee()
                    {
                        EmployeeId = visit.EmployeeId,
                        Email      = "*****@*****.**"
                    };
                }

                return(Task.FromResult(employee));
            };

            visitRepository.UpdateAsyncVisit = (visitParam) =>
            {
                Assert.IsTrue(visitParam.VisitId == visit.VisitId);
                Assert.IsTrue(visitParam.Status == VisitStatus.Arrived);
                called = true;
                return(Task.FromResult(string.Empty));
            };

            var target = new VisitsController(visitRepository, new SecurityHelper(), employeeRepository);
            await target.UpdateStatus(visit.VisitId, VisitStatus.Arrived);

            Assert.IsTrue(called);
        }