public static IFixture CreateFixture()
        {
            var fixture = new Fixture();

            fixture.Customize(new AutoMoqCustomization
            {
                ConfigureMembers  = true,
                GenerateDelegates = true
            });

            fixture.Register(() => new SelectorEqualityComparer <TypeWithProperty <int>, int>(item => item.Property));

            fixture.Register(() => new SelectorEqualityComparer <TypeWithProperty <string>, string>(item => item.Property));

            return(fixture);
        }
        private static IFixture CreateFixture()
        {
            var fixture = new Fixture();

            fixture.Customize(new AutoMoqCustomization
            {
                ConfigureMembers  = true,
                GenerateDelegates = true
            });

            fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            fixture.Customize <HttpResponse>(r => r.Without(p => p.Body));

            fixture.Register(() => Mock.Of <HttpRequest>());

            fixture.Register(() => Mock.Of <HttpResponse>());

            return(fixture);
        }
示例#3
0
        public static IFixture CreateFixture()
        {
            var fixture = new Fixture();

            fixture.Customize(new AutoMoqCustomization
            {
                ConfigureMembers  = true,
                GenerateDelegates = true
            });

            fixture.Register((Uri uri) => new EndpointAddress(uri.ToString()));

            fixture.Register <Binding>(() => new BasicHttpBinding());

            fixture.Register <IServiceCollection>(() => new ServiceCollection());

            fixture.Register((EndpointAddress address, Binding binding) => new Mock <ChannelFactory <ITestService> >(binding, address));

            return(fixture);
        }
示例#4
0
        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);
        }
示例#5
0
        private static IFixture CreateFixture()
        {
            IFixture fixture = new Fixture();

            fixture.Customize(new AutoMoqCustomization
            {
                ConfigureMembers  = true,
                GenerateDelegates = true
            });

            fixture.Register(() => MessageDescriptor.EqualityComparer);

            return(fixture);
        }
        public static IFixture CreateFixture()
        {
            IFixture fixture = new Fixture();

            fixture.Customize(new AutoMoqCustomization
            {
                ConfigureMembers  = true,
                GenerateDelegates = true
            });

            fixture.Register(() => Stream.Null);

            return(fixture);
        }
示例#7
0
        public static IFixture CreateFixture()
        {
            var fixture = new Fixture();

            fixture.Customize(new AutoMoqCustomization
            {
                GenerateDelegates = true,
                ConfigureMembers  = true
            });

            fixture.Register(() =>
            {
                var settings = new JsonSerializerSettings();
                HttpHubSpotClient.ConfigureJsonSerializer(settings);
                return(settings);
            });

            fixture.Register((HttpHubSpotClient client) => client.Companies);

            fixture.Register((HttpHubSpotClient client) => client.Contacts);

            fixture.Register((HttpHubSpotClient client) => client.Crm);

            fixture.Register((HttpHubSpotClient client) => client.Deals);

            fixture.Register((HttpHubSpotClient client) => client.Lists);

            fixture.Register((HttpHubSpotClient client) => client.Owners);

            fixture.Register((HttpHubSpotClient client) => client.Contacts.Properties);

            fixture.Register((HttpHubSpotClient client) => client.Contacts.PropertyGroups);

            fixture.Register((HttpHubSpotClient client) => client.Crm.Associations);

            return(fixture);
        }
        private static IFixture CreateFixture()
        {
            var fixture = new Fixture();

            fixture.AddGrpcSupport();

            fixture.Customize(new AutoMoqCustomization
            {
                ConfigureMembers  = true,
                GenerateDelegates = true
            });

            fixture.Register(Mock.Of <Greeter.GreeterClient>);

            return(fixture);
        }
示例#9
0
        private static IFixture CreateFixture()
        {
            IFixture fixture = new Fixture();

            fixture.Customize(new AutoMoqCustomization
            {
                ConfigureMembers  = true,
                GenerateDelegates = true
            });

            fixture.Customizations.Add(new TypeRelay(typeof(ISerializer), typeof(JsonSerializer)));

            fixture.Customizations.Add(new TypeRelay(typeof(IMessageDescriptorStore), typeof(TestMessageDescriptorStore)));

            fixture.Register(() => TemporaryQueueFactory.Instance as TemporaryQueueFactory);

            fixture.Customizations.Add(new ElementsBuilder <Encoding>(Encoding.GetEncodings().Select(e => e.GetEncoding())));

            fixture.Customize <RabbitMqOptions>(c => c.With(p => p.OutboundEncoding, (Encoding encoding) => encoding.WebName));

            return(fixture);
        }
示例#10
0
        public static IFixture CreateFixture()
        {
            var fixture = new Fixture();

            fixture.Customize(new AutoMoqCustomization
            {
                ConfigureMembers  = true,
                GenerateDelegates = true
            });

            fixture.Register((string program, string args) => new ProcessStartInfo {
                FileName = program, Arguments = args
            });

            fixture.Inject(new TokenOptions());

            fixture.Customize <GetObjectMetadataResponse>(c => c.Without(p => p.RequestCharged));

            fixture.Customize <PutObjectResponse>(c => c.Without(p => p.RequestCharged));

            fixture.Customize <DeleteObjectResponse>(c => c.Without(p => p.RequestCharged));

            return(fixture);
        }