public async Task SegmentServiceGetByNameReturnsNullWhenMissingInRepository() { // arrange CurrentOpportunitiesSegmentModel expectedResult = null; A.CallTo(() => FakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(expectedResult); // act var result = await CurrentOpportunitiesSegmentService.GetByNameAsync("article-name").ConfigureAwait(false); // assert A.CallTo(() => FakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly(); A.Equals(result, expectedResult); }
public async Task SegmentServiceGetByNameReturnsSuccess() { // arrange Guid documentId = Guid.NewGuid(); var expectedResult = A.Fake <CurrentOpportunitiesSegmentModel>(); A.CallTo(() => FakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(expectedResult); // act var result = await CurrentOpportunitiesSegmentService.GetByNameAsync("article-name").ConfigureAwait(false); // assert A.CallTo(() => FakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly(); A.Equals(result, expectedResult); }
public async Task SegmentServiceGetByNameReturnsArgumentNullExceptionWhenNullIsUsed() { // arrange // act var exceptionResult = await Assert.ThrowsAsync <ArgumentNullException>(async() => await CurrentOpportunitiesSegmentService.GetByNameAsync(null).ConfigureAwait(false)).ConfigureAwait(false); // assert Assert.Equal("Value cannot be null. (Parameter 'canonicalName')", exceptionResult.Message); }