public static IDiverRepository CreateRepository() { var result = A.Fake <IDiverRepository>(); A.CallTo(() => result.FindByIdAsync(A <Guid> ._)) .ReturnsLazily(call => Task.FromResult( (Guid)call.Arguments[0] == DiverFactory.JohnDoeDiverId ? DiverFactory.CreateJohnDoe() : null)); A.CallTo(() => result.GetAllTauchboldeUsersAsync(A <bool> ._)) .ReturnsLazily(() => Task.FromResult <ICollection <Diver> >( new List <Diver> { DiverFactory.CreateJohnDoe(), })); A.CallTo(() => result.GetAllDiversAsync()) .ReturnsLazily(() => Task.FromResult <ICollection <Diver> >( new List <Diver> { DiverFactory.CreateJohnDoe(), DiverFactory.CreateJaneDoe(), })); A.CallTo(() => result.FindByUserNameAsync(A <string> ._)) .ReturnsLazily(call => Task.FromResult( (string)call.Arguments[0] == DiverFactory.JohnDoeUserName ? DiverFactory.CreateJohnDoe() : null)); return(result); }
public static ICurrentUser CreateCurrentUser() { var result = A.Fake <ICurrentUser>(); A.CallTo(() => result.Username).Returns(DiverFactory.JohnDoeUserName); A.CallTo(() => result.GetCurrentDiverAsync()) .ReturnsLazily(() => Task.FromResult(DiverFactory.CreateJohnDoe())); A.CallTo(() => result.GetIsDiverOrAdmin(A <Guid> ._)) .ReturnsLazily(call => Task.FromResult( (Guid)call.Arguments[0] == DiverFactory.JohnDoeDiverId)); return(result); }