Exemplo n.º 1
0
        public void CreateList_creates_new_object_list_with_transformation()
        {
            const int LIST_SIZE = 20;
            var       factory   = FactoryAlien.Define <DummyObject>();

            var createdList = factory.CreateList(LIST_SIZE, c =>
            {
                c.StringProperty  = "RIO2016";
                c.IntProperty     = 12345;
                c.DecimalProperty = 123.45M;
            });

            Assert.NotNull(createdList);
            Assert.NotEmpty(createdList);
            Assert.Equal(LIST_SIZE, createdList.Count());

            var createdObjects = createdList.ToArray();

            for (int i = 0; i < LIST_SIZE; i++)
            {
                Assert.NotNull(createdObjects[i]);
                Assert.Equal(createdObjects[i].StringProperty, "RIO2016");
                Assert.Equal(createdObjects[i].IntProperty, 12345);
                Assert.Equal(createdObjects[i].DecimalProperty, 123.45M);
            }
        }
        public RepositoryTests()
        {
            _dbContextMock    = new Mock <DbContext>();
            _productDbSetMock = new Mock <DbSet <Product> >();

            _repository     = new ProductRepository(_dbContextMock.Object);
            _productFactory = FactoryAlien.Define <Product>();
        }
Exemplo n.º 3
0
        public void generate_random_enum_values()
        {
            var factory = FactoryAlien.Define <DummyObject>();

            var createdObject = factory.CreateOne();

            Assert.NotNull(createdObject.NullableEnumProperty);
        }
Exemplo n.º 4
0
        public void CreateOne_creates_new_object()
        {
            var factory = FactoryAlien.Define <DummyObject>();

            var createdObject = factory.CreateOne();

            Assert.NotNull(createdObject);
        }
Exemplo n.º 5
0
        public void generate_random_integer_values()
        {
            var factory = FactoryAlien.Define <DummyObject>();

            var createdObject = factory.CreateOne();

            Assert.True(createdObject.IntProperty > 0);
            Assert.True(createdObject.NullableIntProperty > 0);
        }
Exemplo n.º 6
0
        public void generate_random_string_values()
        {
            var factory = FactoryAlien.Define <DummyObject>();

            var createdObject = factory.CreateOne();

            Assert.NotNull(createdObject.StringProperty);
            Assert.NotEmpty(createdObject.StringProperty);
            Assert.Equal(createdObject.StringProperty.Length, RANDOM_STRING_SIZE);
        }
Exemplo n.º 7
0
        public void CreateList_creates_new_object_list()
        {
            const int LIST_SIZE = 20;
            var       factory   = FactoryAlien.Define <DummyObject>();

            var createdList = factory.CreateList(LIST_SIZE);

            Assert.NotNull(createdList);
            Assert.NotEmpty(createdList);
            Assert.Equal(LIST_SIZE, createdList.Count());
        }
Exemplo n.º 8
0
        public void generate_random_datetime_values()
        {
            var factory = FactoryAlien.Define <DummyObject>();

            var createdObject = factory.CreateOne();

            DateTime minDateTime = DateTime.Now.AddMonths(-6);

            Assert.True(createdObject.DateTimeProperty >= minDateTime);
            Assert.True(createdObject.DateTimeProperty >= minDateTime);
        }
Exemplo n.º 9
0
        public void build_random_list_with_fluent_interface()
        {
            var factory = FactoryAlien.Define <DummyObject>();

            var buildableList = factory.CreateList(5, c => c.StringProperty = "BRAZIL");

            buildableList.Add(4)
            .Add(3, c => c.StringProperty = "EUA")
            .Add(2, c => c.StringProperty = "CANADA");

            Assert.Equal(14, buildableList.Count());
            Assert.Equal(5, buildableList.Count(c => c.StringProperty == "BRAZIL"));
            Assert.Equal(3, buildableList.Count(c => c.StringProperty == "EUA"));
            Assert.Equal(2, buildableList.Count(c => c.StringProperty == "CANADA"));
        }
Exemplo n.º 10
0
        public void CreateOne_creates_new_object_with_transformation()
        {
            var factory = FactoryAlien.Define <DummyObject>();

            var createdObject = factory.CreateOne(c =>
            {
                c.StringProperty  = "RIO2016";
                c.IntProperty     = 12345;
                c.DecimalProperty = 123.45M;
            });

            Assert.NotNull(createdObject);
            Assert.Equal(createdObject.StringProperty, "RIO2016");
            Assert.Equal(createdObject.IntProperty, 12345);
            Assert.Equal(createdObject.DecimalProperty, 123.45M);
        }