public void Should_handle_basic_CRUD_operations()
        {
            // arrange
            var target = new TestTarget
            {
                Id = 0,
                Data = new TestTargetData
                {
                    TestString = "Test Target Data"
                }
            };
            var dataProvider = new MssqlDataProvider();
            var repository = new TargetRepository(dataProvider);

            // act
            var result = repository.Update(target);

            // assert
            Assert.That(result, Is.GreaterThan(0));

            // now Get
            var persistedTarget = repository.Get<TestTarget>(target.TableName, result);
            Assert.That(persistedTarget.Id, Is.GreaterThan(0));
            Assert.That(persistedTarget.Data, Is.Not.Null);

            var targetData = (TestTargetData) persistedTarget.Data;
            Assert.That(targetData.TestString, Is.EqualTo("Test Target Data"));

            // remove the record
            repository.Delete(persistedTarget);
        }
Exemple #2
0
        public void Should_handle_basic_CRUD_operations()
        {
            // arrange
            var target = new TestTarget
            {
                Id   = 0,
                Data = new TestTargetData
                {
                    TestString = "Test Target Data"
                }
            };
            var dataProvider = new MssqlDataProvider();
            var repository   = new TargetRepository(dataProvider);

            // act
            var result = repository.Update(target);

            // assert
            Assert.That(result, Is.GreaterThan(0));

            // now Get
            var persistedTarget = repository.Get <TestTarget>(target.TableName, result);

            Assert.That(persistedTarget.Id, Is.GreaterThan(0));
            Assert.That(persistedTarget.Data, Is.Not.Null);

            var targetData = (TestTargetData)persistedTarget.Data;

            Assert.That(targetData.TestString, Is.EqualTo("Test Target Data"));

            // remove the record
            repository.Delete(persistedTarget);
        }
Exemple #3
0
        public void TargetRepository()
        {
            Mock <IDbSetFactory>   factory = new Mock <IDbSetFactory>();
            Mock <DbSet <Target> > dbSet   = new Mock <DbSet <Target> >();

            factory.Setup(m => m.CreateDbSet <Target>()).Returns(dbSet.Object);

            TargetRepository repo = new TargetRepository(factory.Object);

            var Target = new Target();

            var sequence = new MockSequence();

            dbSet.InSequence(sequence).Setup(e => e.Add(Target));
            dbSet.InSequence(sequence).Setup(e => e.Find(Target.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Target.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Target.Id));
            repo.Create(Target);
            repo.Get(Target.Id);
            repo.Update(Target);
            repo.Delete(Target.Id);
        }
        public void TargetRepository()
        {
            Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>();
            Mock<DbSet<Target>> dbSet = new Mock<DbSet<Target>>();

            factory.Setup(m => m.CreateDbSet<Target>()).Returns(dbSet.Object);

            TargetRepository repo = new TargetRepository(factory.Object);

            var Target = new Target();

            var sequence = new MockSequence();
            dbSet.InSequence(sequence).Setup(e => e.Add(Target));
            dbSet.InSequence(sequence).Setup(e => e.Find(Target.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Target.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Target.Id));
            repo.Create(Target);
            repo.Get(Target.Id);
            repo.Update(Target);
            repo.Delete(Target.Id);
        }