public async Task MeetingTypeControllerGetAdmin() { var data = new MeetingTypeApiDataHandler(); var model = MeetingTypeData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <MeetingType> >())).Returns(model); var controller = new MeetingTypeController(data, Logic) { CurrentUser = AdminUser }; var result = await controller.Get(MeetingTypeData.FirstId) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); var viewModel = result.Value as MeetingTypeViewModel; viewModel.Id.Should().Be(model.Id); viewModel.Name.Should().Be(model.Name); viewModel.DaysWhen.Should().Be(model.DaysWhen); data.HasExecuted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <MeetingType> >()), Times.Once()); }
public async Task MeetingTypeControllerGetNull() { var data = new MeetingTypeApiDataHandler(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <MeetingType> >())).Returns(null); var controller = new MeetingTypeController(data, Logic) { CurrentUser = StandardUser }; var result = await controller.Get(MeetingTypeData.FirstId) as NotFoundResult; result.Should().NotBeNull(); result.Should().BeOfType <NotFoundResult>(); data.HasExecuted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <MeetingType> >()), Times.Once()); }
public async Task MeetingTypeControllerGetUnauthorised() { var data = new MeetingTypeApiDataHandler(); var model = MeetingTypeData.GetFirst(); data.Result.Setup(m => m.Execute(It.IsAny <Loader <MeetingType> >())).Returns(model); var controller = new MeetingTypeController(data, Logic) { CurrentUser = NonTenantUser }; var result = await controller.Get(MeetingTypeData.FirstId) as UnauthorizedResult; result.Should().NotBeNull(); result.Should().BeOfType <UnauthorizedResult>(); data.HasExecuted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <Loader <MeetingType> >()), Times.Once()); }