Exemplo n.º 1
0
        public void InsertTest()
        {
            // --====================================================== Assigenment
            _entity = new CrudEntity
            {
                Id        = 1,
                BirthDate = new DateTime(2019, 1, 1),
                Name      = "Crud",
                Year      = 20154,
            };

            // --====================================================== Action
            EntityService.Insert(_entity);

            // --====================================================== Assertion
            var entity = EntityService.LoadEntity(_entity.Id);

            Assert.AreEqual(new DateTime(2019, 1, 1), entity.BirthDate);
            Assert.AreEqual("Crud", entity.Name);
            Assert.AreEqual(20154, entity.Year);
        }
Exemplo n.º 2
0
        public void Init()
        {
            new DependencyInitializer()
            .TestMode(true)
            .ForAssembly(GetType().Assembly)
            .Init((dbConfig, container) =>
            {
                dbConfig["Core.NUnitTest.Tests.CRUD"] = "Core";

                _scope     = container.BeginScope();
                _container = container;
            });

            _container.InjectProperties(this);


            using (DataConnection context = new DataConnection("Core"))
            {
                var schema = context.DataProvider.GetSchemaProvider().GetSchema(context);

                // Создание таблиц для сущности LoggingEntity
                if (schema.Tables.Any(table => table.TableName == typeof(CrudEntity).GetCustomAttribute <TableAttribute>().Name))
                {
                    context.DropTable <CrudEntity>();
                }

                context.CreateTable <CrudEntity>();

                _entity = new CrudEntity
                {
                    Id        = 1,
                    BirthDate = new DateTime(2019, 1, 1),
                    Name      = "Crud",
                    Year      = 20154,
                };


                EntityService.Insert(_entity);
            }
        }