public void 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 testService = new SubmissionService( mockDataRepo.Object, mockScopeBL.Object, _mockDraftFileBL.Object); // Assert Return actualReturn = testService.GetReturnFromDatabase(1, 1998); Expect(actualReturn == null); }
public void GetSubmissionForSnapshotYear_Returns_latest_submission_for_specified_org_and_year() { // 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 <SubmissionService>( mockDataRepo.Object, mockScopeBL.Object, _mockDraftFileBL.Object); mockService.CallBase = true; mockService.Setup(s => s.IsValidSnapshotYear(It.IsAny <int>())).Returns(true); // Assert SubmissionService testService = mockService.Object; Return actualReturn = testService.GetReturnFromDatabase(1, 2000); Expect(actualReturn != null); Expect(actualReturn.ReturnId == 4); }