public async Task GetSubmissionForSnapshotYear_Returns_null_when_year_does_not_exist() { // Mocks mockDataRepo.Setup(dr => dr.GetAll <Return>()) .Returns( new[] { new Return { ReturnId = 1, OrganisationId = 2, AccountingDate = new DateTime(1999, 1, 1) }, new Return { ReturnId = 2, OrganisationId = 1, AccountingDate = new DateTime(1999, 1, 2) }, new Return { ReturnId = 3, OrganisationId = 1, AccountingDate = new DateTime(2000, 1, 3) }, new Return { ReturnId = 4, OrganisationId = 1, AccountingDate = new DateTime(2000, 1, 4) }, new Return { ReturnId = 5, OrganisationId = 2, AccountingDate = new DateTime(2000, 1, 5) } }.AsQueryable() .BuildMock() .Object); var sharedBusinessLogic = UiTestHelper.DIContainer.Resolve <ISharedBusinessLogic>(); var testSubmissionService = new SubmissionService(sharedBusinessLogic, Mock.Of <ISubmissionBusinessLogic>(), Mock.Of <IScopeBusinessLogic>(), Mock.Of <IDraftFileBusinessLogic>()); var testPresenter = new SubmissionPresenter(testSubmissionService, ConfigHelpers.SubmissionOptions, null); // Assert Return actualReturn = await testPresenter.GetReturnFromDatabaseAsync(1, 1998); Expect(actualReturn == null); }
public async Task GetSubmissionForSnapshotYear_Returns_latest_submission_for_specified_org_and_yearAsync() { // Mocks var returns = new[] { new Return { ReturnId = 1, OrganisationId = 2, AccountingDate = new DateTime(1999, 1, 1), Status = ReturnStatuses.Submitted }, new Return { ReturnId = 2, OrganisationId = 1, AccountingDate = new DateTime(1999, 1, 2), Status = ReturnStatuses.Submitted }, new Return { ReturnId = 3, OrganisationId = 1, AccountingDate = new DateTime(2000, 1, 3), Status = ReturnStatuses.Submitted }, new Return { ReturnId = 4, OrganisationId = 1, AccountingDate = new DateTime(2000, 1, 4), Status = ReturnStatuses.Submitted }, new Return { ReturnId = 5, OrganisationId = 2, AccountingDate = new DateTime(2000, 1, 5), Status = ReturnStatuses.Submitted } }; mockDataRepo.SetupGetAll((ICollection <Return>)returns); var mockService = new Mock <SubmissionPresenter>( mockDataRepo.Object, mockScopeBL.Object, mockFileRepo.Object, _mockDraftFileBL.Object, null); mockService.CallBase = true; mockService.Setup(s => s.IsValidSnapshotYear(It.IsAny <int>())).Returns(true); // Assert SubmissionPresenter testService = mockService.Object; Return actualReturn = await testService.GetReturnFromDatabaseAsync(1, 2000); Expect(actualReturn != null); Expect(actualReturn.ReturnId == 4); }