예제 #1
0
파일: CrudTests.cs 프로젝트: lukich48/Core
        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);
        }
예제 #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);
            }
        }