Example #1
0
        public void SetUp()
        {
            autoFaker = new AutoFakerFactory()
                        .AddDraftsBuilderEntitiesGeneration()
                        .Create();

            var payerInn   = autoFaker.Generate <Inn>();
            var senderInn  = autoFaker.Generate <Inn>();
            var senderCert = autoFaker.Generate <byte[]>();
            var ifnsCode   = autoFaker.Generate <IfnsCode>();
            var mriCode    = autoFaker.Generate <MriCode>();

            payer     = DraftPayer.IndividualEntrepreneur(payerInn);
            sender    = DraftSender.IndividualEntrepreneur(senderInn, senderCert);
            recipient = DraftRecipient.Ifns(ifnsCode, mriCode);

            expectedRequestPrototype = new DraftsBuilderMetaRequest(
                new SenderRequest
            {
                Inn         = senderInn.ToString(),
                Certificate = new PublicKeyCertificateRequest
                {
                    Content = senderCert
                }
            },
                new AccountInfoRequest
            {
                Inn = payerInn.ToString()
            },
                new RecipientInfoRequest
            {
                IfnsCode = ifnsCode,
                MriCode  = mriCode
            },
Example #2
0
        public void Atualizar()
        {
            var drone  = _autoFaker.Generate <DroneEntity>();
            var result = _repositoryDrone.Atualizar(drone);

            Assert.Equal(Task.CompletedTask, result);
        }
Example #3
0
        public async Task Atualizar_test()
        {
            //Given(Preparação)
            using var dbconnection = await new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider).OpenAsync();
            var baseRepositoryMock = new PedidosRepository(dbconnection);

            dbconnection.CreateTableIfNotExists <Pedido>();
            var expectresult = _faker.Generate <Pedido>();

            await dbconnection.InsertAsync(expectresult);

            expectresult.Peso = 1;

            var param = expectresult.ConvertTo <PedidoEntity>();

            //When

            await baseRepositoryMock.Atualizar(param);

            var result = await dbconnection.SingleAsync <Pedido>(p => p.Id == expectresult.Id);

            //Then

            Assert.True(_comparison.Compare(result, expectresult).AreEqual);
        }
        public async Task Post_HttpStatusCodeUnauthorizedTestAsync()
        {
            var customer = _autoFaker.Generate <Customer>();

            var response = await _httpClient.PostAsync("/api/v1/customers", new StringContent(JsonConvert.SerializeObject(customer)));

            Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
        }
Example #5
0
        protected ServiceFixture(ITestOutputHelper output, IAutoBinder binder)
        {
            _faker = AutoFaker.Create(builder =>
            {
                builder.WithOverride(new ProductGeneratorOverride());

                if (binder != null)
                {
                    builder.WithBinder(binder);
                }
            });

            // Setup
            var id        = _faker.Generate <Guid>();
            var generator = new AutoFaker <Item>(binder)
                            .RuleFor(item => item.Id, () => id)
                            .RuleFor(item => item.Name, faker => faker.Person.FullName)
                            .RuleFor(item => item.Amendments, faker => new HashSet <string> {
                "1", "2", "3"
            });

            _item  = generator;
            _items = generator.Generate(5);

            _repository = Substitute.For <IRepository>();

            _repository.Get(id).Returns(_item);
            _repository.GetAll().Returns(_items);

            _service = new Service(_repository);
            _output  = output;
        }
Example #6
0
        public void Service_GetPending_Should_Return_Items()
        {
            var id            = _faker.Generate <Guid>();
            var item          = AutoFaker.Generate <Item>();
            var item1Override = new ProductCodeOverride();
            var item2Override = new ProductCodeOverride();
            var items         = new List <Item>
            {
                _faker.Generate <Item, ItemFaker>(builder => builder.WithArgs(id).WithOverride(item1Override)),
                AutoFaker.Generate <Item, ItemFaker>(builder => builder.WithArgs(id).WithOverride(item2Override)),
                AutoFaker.Generate <Item>(builder => builder.WithSkip <Item>(i => i.ProcessedBy)),
                AutoFaker.Generate <Item>(builder => builder.WithConventions(c => c.Email.Aliases("SupplierEmail")))
            };

            item.Status = ItemStatus.Pending;
            items.Add(item);

            _repository.GetFiltered(Service.PendingFilter).Returns(items);

            _service.GetPending().Should().BeSameAs(items);

            items.ElementAt(0).ProcessedBy.Email.Should().NotContain("@");
            items.ElementAt(0).SupplierEmail.Should().NotContain("@");
            items.ElementAt(0).ProductInt.Code.SerialNumber.Should().Be(item1Override.Code);
            items.ElementAt(0).ProductString.Code.SerialNumber.Should().Be(item1Override.Code);

            items.ElementAt(1).ProcessedBy.Email.Should().NotContain("@");
            items.ElementAt(1).SupplierEmail.Should().NotContain("@");
            items.ElementAt(1).ProductInt.Code.SerialNumber.Should().Be(item2Override.Code);
            items.ElementAt(1).ProductString.Code.SerialNumber.Should().Be(item2Override.Code);

            items.ElementAt(2).ProcessedBy.Should().BeNull();
            items.ElementAt(2).SupplierEmail.Should().NotContain("@");
            items.ElementAt(2).ProductInt.Code.SerialNumber.Should().BeNull();
            items.ElementAt(2).ProductString.Code.SerialNumber.Should().BeNull();

            items.ElementAt(3).ProcessedBy.Email.Should().Contain("@");
            items.ElementAt(3).SupplierEmail.Should().Contain("@");
            items.ElementAt(3).ProductInt.Code.SerialNumber.Should().BeNull();
            items.ElementAt(3).ProductString.Code.SerialNumber.Should().BeNull();

            items.ElementAt(4).ProcessedBy.Email.Should().NotContain("@");
            items.ElementAt(4).SupplierEmail.Should().NotContain("@");
            items.ElementAt(4).ProductInt.Code.SerialNumber.Should().BeNull();
            items.ElementAt(4).ProductString.Code.SerialNumber.Should().BeNull();
        }
Example #7
0
        public void MapCard_DtoNotNull_Success()
        {
            // arrange
            var mapper = new ModelMapper();
            var dto    = _faker.Generate <CardDto>();

            // act
            var model = mapper.MapCard(dto);

            // assert
            foreach (var(Name, Value, PropType) in GetAllPropertyNames(dto))
            {
                var modelValue = GetPropValue(model, Name);
                if (PropType == modelValue.Type)
                {
                    Assert.Equal(Value, modelValue.Value);
                }
            }
        }
Example #8
0
        public void Should_Not_Apply_Conventions_For_Disabled_Generator()
        {
            _faker = AutoFaker.Create(builder =>
            {
                builder.WithConventions(c => c.Email.Enabled = false);
            });

            var instance = _faker.Generate <TestClass>();

            instance.Email.Should().NotContain("@");
        }
Example #9
0
        public void Should_Apply_Conventions_For_Alias()
        {
            _faker = AutoFaker.Create(builder =>
            {
                builder.WithConventions(c => c.Email.Aliases("anotheremail", "  "));
            });

            var instance = _faker.Generate <TestClass>();

            instance.AnotherEmail.Should().Contain("@");
        }
Example #10
0
        public void Should_Apply_Conventions()
        {
            _faker = AutoFaker.Create(builder =>
            {
                builder.WithConventions();
            });

            var instance = _faker.Generate <TestClass>();

            instance.Email.Should().Contain("@");
        }
Example #11
0
        public void Should_Not_Apply_Conventions_When_Generator_AlwaysGenerate_Is_False()
        {
            _faker = AutoFaker.Create(builder =>
            {
                builder
                .WithOverride(new TestGeneratorOverride())
                .WithConventions(c => c.Email.AlwaysGenerate = false);
            });

            var instance = _faker.Generate <TestClass>();

            instance.Email.Should().Be("EMAIL");
        }
Example #12
0
        public void Generate_ExampleStruct()
        {
            IAutoFaker faker = AutoFaker.Create(builder =>
            {
                builder.WithOverride(new ExampleStructOverride());
            });

            var exampleStruct = faker.Generate <ExampleStruct>();

            _outputHelper.WriteLine(exampleStruct.Month.ToString());

            Assert.True(exampleStruct.Month > 0 && exampleStruct.Month <= 12);
        }
            public void Should_Generate_Complex_Type()
            {
                var configure = CreateConfigure <IAutoGenerateConfigBuilder>(_config);

                _faker.Generate <Order>(configure).Should().BeGeneratedWithoutMocks();
            }
 public void Should_Generate_Complex_Type()
 {
     _faker.Generate <Order, TestFaker>(new object[0]).Should().BeGeneratedWithoutMocks();
 }
        public T GenerateWithData(Type?dataType, DraftBuilderType draftBuilderType)
        {
            var data = dataType is null?unknownDataFactory() : (TData?)faker.Generate(dataType) ?? unknownDataFactory();

            return(Generate(draftBuilderType, data));
        }
 public DronesRepositoryFake()
 {
     _autoFaker = AutoFaker.Create();
     _drones    = _autoFaker.Generate <List <DroneEntity> >();
 }
 public void Should_Create_With_Mocks()
 {
     _faker.Generate <Order>().Should().BeGeneratedWithMocks();
 }
Example #18
0
 public void Should_Generate_Complex_Type()
 {
     _faker.Generate <Order>().Should().BeGeneratedWithoutMocks();
 }