private static IFixture CreateFixture() { IFixture fixture = new Fixture(); fixture.Customize(new AutoMoqCustomization { ConfigureMembers = true, GenerateDelegates = true }); fixture.Freeze <IServiceProvider>(); return(fixture); }
private static IFixture CreateFixture() { IFixture fixture = new Fixture(); fixture.Customize(new AutoMoqCustomization { ConfigureMembers = true, GenerateDelegates = true }); fixture.Freeze <IServiceProvider>(); fixture.Customizations.Add(new TypeRelay(typeof(IMessageDescriptorStore), typeof(TestMessageDescriptorStore))); return(fixture); }
public void Level_Serialize() { var fixture = new Fixture(); fixture.Customize(new AutoMoqCustomization()); var level = fixture.Build <RegularPongLevel>().OmitAutoProperties().Create(); level.Initialize(); var content = fixture.Freeze <Mock <IContentManager> >(); content.Setup(p => p.Load <Texture2D>(It.IsAny <string>())).Returns(value: null); level.LoadContent(content.Object, fixture.Create <Point>()); level.SaveGame(); }
public async Task GetUsersAsyncReturnsListOfUsers() { var fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true }); var users = fixture.CreateMany <User>(); var repoMock = new Mock <IRepository <User> >(); var uowEfMock = new Mock <IUnitOfWorkEf>(); repoMock.Setup(x => x.GetAllAsync()).ReturnsAsync(users); uowEfMock.Setup(x => x.Repository <User>()).Returns(repoMock.Object); fixture.Register(() => repoMock.Object); fixture.Register(() => uowEfMock.Object); fixture.Inject <IUsersService>(fixture.Freeze <UsersService>()); var sut = fixture.Create <UsersController>(); var result = (OkObjectResult)await sut.Get(); var usersResult = (IList <UserEditionDto>)result.Value; users.ToList().Count.Should().Be(usersResult.Count); }
public async Task GetTest() { //Arrange var fixture = new Fixture(); fixture.Customize(new AutoMoqCustomization()); var url = "http://service-app:8000"; var expectedResult = new List <AnimalDto>() { new AnimalDto() { Id = 1, Name = "Cat" }, new AnimalDto() { Id = 2, Name = "Dog" } }; fixture.Customize <ServiceConfiguration>(cfg => cfg.With(x => x.Url, url)); var serviceConfiguration = fixture.Freeze <Mock <ServiceConfiguration> >(); var sut = fixture.Create <ClientAnimalsController>(); using (var httpTest = new HttpTest()) { httpTest.RespondWithJson(expectedResult); //Act var result = await sut.Get(); //Assert result.Join(expectedResult, r => r.Id, e => e.Id, (r, e) => e).Count().Should().Be(expectedResult.Count); httpTest.ShouldHaveCalled(url + "/api/animals"); } }