예제 #1
0
        public void InsertMultipleTest()
        {
            var repository = LocalIoCContainer.Resolve <ISimpleDataEntityRepository>();

            var actual1 = repository.Count();

            var newItem1 = new SimpleDataEntity {
                Name = "Multiple Item 1"
            };
            var newItem2 = new SimpleDataEntity {
                Name = "Multiple Item 2"
            };
            var newItem3 = new SimpleDataEntity {
                Name = "Multiple Item 3"
            };
            var actual = repository.Add(new List <SimpleDataEntity>
            {
                newItem1
                , newItem2
                , newItem3
            });
            var result = repository.Save();

            var actual2 = repository.Count();

            Assert.AreEqual(7, actual1);
            Assert.AreEqual(10, actual2);

            repository.Dispose();
        }
예제 #2
0
        protected override void Seed(DatabaseInitialization.TestDatabase context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            var mydata1 = new SimpleDataEntity {
                Name = "Hello Test 2"
            };
            var mydata2 = new SimpleDataEntity {
                Name = "Hello Test Again 2"
            };

            context.SimpleDataEntities.AddOrUpdate(mydata1);
            context.SimpleDataEntities.AddOrUpdate(mydata2);
            context.SaveChanges();
        }
        public void DeltaTestInvalidFieldName1Audit()
        {
            var repository = LocalIoCContainer.Resolve <ISimpleDataEntityRepository>();
            var newItem    = new SimpleDataEntity {
                Name = "Delta Test"
            };
            var actual = repository.Add(newItem);
            var result = repository.Save();

            var delta1 = new Delta <SimpleDataEntity>();

            delta1.SetValue("NameNotRight", "Right data type");
        }
        public void DeltaTestWrongDataType1Audit()
        {
            var repository = LocalIoCContainer.Resolve <ISimpleDataEntityRepository>();
            var newItem    = new SimpleDataEntity {
                Name = "Delta Test"
            };
            var actual = repository.Add(newItem);
            var result = repository.Save();

            var delta1 = new Delta <SimpleDataEntity>();

            delta1.SetValue("Name", 1);
        }
        protected override void Seed(YourCustomDataContext context)
        {
            var mydata1 = new SimpleDataEntity {
                Name = "Hello Test"
            };
            var mydata2 = new SimpleDataEntity {
                Name = "Hello Test Again"
            };

            context.SimpleDataEntities.Add(mydata1);
            context.SimpleDataEntities.Add(mydata2);
            context.SaveChanges();
        }
        protected override void Seed(YourCustomDataContext context)
        {
            var mydata1 = new SimpleDataEntity {
                Name = "Hello Test 2"
            };
            var mydata2 = new SimpleDataEntity {
                Name = "Hello Test Again 2"
            };

            context.SimpleDataEntities.Add(mydata1);
            context.SimpleDataEntities.Add(mydata2);
            var result = context.SaveChangesAsync().Result;
        }
        public void DeltaTestFailWithPredicateAudit()
        {
            var repository = LocalIoCContainer.Resolve <ISimpleDataEntityRepository>();
            var newItem    = new SimpleDataEntity {
                Name = "Delta Test"
            };
            var actual = repository.Add(newItem);
            var result = repository.Save();

            var delta1 = new Delta <SimpleDataEntity>();

            delta1.SetValue("Name", "Delta Change Test");

            repository.Update(delta1, x => x.Id == 55);
        }
예제 #8
0
        protected void Seed(TestDatabase context)
        {
            var mydata1 = new SimpleDataEntity {
                Name = "Hello Test 2"
            };
            var mydata2 = new SimpleDataEntity {
                Name = "Hello Test Again 2"
            };

            //var anotherData = new AnotherData2 { Name = "Composite 1" };

            context.SimpleDataEntities.Add(mydata1);
            context.SimpleDataEntities.Add(mydata2);
            //context.AnotherDataElements.Add(anotherData);
            context.SaveChanges();
        }
예제 #9
0
        public void InsertTestMethod3()
        {
            var repository = LocalIoCContainer.Resolve <ISimpleDataEntityRepository>();
            var newItem    = new SimpleDataEntity {
                Name = "My Test 300"
            };
            var actual = repository.Add(newItem);
            var result = repository.Save();

            Assert.AreNotEqual(0, actual.Id);

            var actual2 = repository.Find(actual.Id);

            Assert.AreEqual("My Test 300", actual2.Name);

            repository.Dispose();
        }
        protected void Seed(TestDatabase context)
        {
            var simpleDataEntity1 = new SimpleDataEntity {
                Name = "Hello Test 2"
            };
            var simpleDataEntity2 = new SimpleDataEntity {
                Name = "Hello Test Again 2"
            };
            var simpleCompositeKeyEntity = new SimpleCompositeKeyEntity {
                Name = "Composite 1"
            };

            context.SimpleDataEntities.Add(simpleDataEntity1);
            context.SimpleDataEntities.Add(simpleDataEntity2);
            context.SimpleCompositeKeyEntities.Add(simpleCompositeKeyEntity);
            context.SaveChanges();
        }
        public void DeltaTest1Audit()
        {
            var repository = LocalIoCContainer.Resolve <ISimpleDataEntityRepository>();
            var newItem    = new SimpleDataEntity {
                Name = "Delta Test"
            };
            var actual = repository.Add(newItem);
            var result = repository.Save();

            var delta1 = new Delta <SimpleDataEntity>();

            delta1.SetValue("Name", "Delta Change Test");

            repository.Update(delta1, newItem.Id);

            repository.Save();

            var updatedValue = repository.Find(actual.Id);

            Assert.AreEqual("Delta Change Test", updatedValue.Name);
        }