예제 #1
0
        public void ReturnAllMatchingObjects()
        {
            // Arrange
            Bootstrapper.Start();

            var repository        = Bootstrapper.AmbientContainer.GetInstance <Repository <TestModel> >();
            var unitOfWorkFactory = Bootstrapper.AmbientContainer.GetInstance <IUnitOfWorkFactory>();
            var unitOfWork        = unitOfWorkFactory.CreateUnitOfWork();

            var testModel01 = new TestModel("ABCDEF");
            var testModel02 = new TestModel("HIJKLM");
            var testModel03 = new TestModel("ABCZZZ");

            // Act
            using (unitOfWork.Start())
            {
                repository.Create(testModel01);
                repository.Create(testModel02);
                repository.Create(testModel03);

                unitOfWork.Commit();
            }

            // Assert
            using (unitOfWork.Start())
            {
                var foundModel = repository.Find.AllMatchingSpecification(TestModelSpecifications.TestPropertyStartsWithABC()).ToList();

                Assert.That(foundModel.Count.Equals(2));
            }
        }
예제 #2
0
        public void ReturnsEmptyEnumerationGivenNoMatchingObjects()
        {
            // Arrange
            Bootstrapper.Start();

            var repository        = Bootstrapper.AmbientContainer.GetInstance <Repository <TestModel> >();
            var unitOfWorkFactory = Bootstrapper.AmbientContainer.GetInstance <IUnitOfWorkFactory>();
            var unitOfWork        = unitOfWorkFactory.CreateUnitOfWork();

            var testModel01 = new TestModel("BLARG");
            var testModel02 = new TestModel("BENNY");
            var testModel03 = new TestModel("BOOFY");

            // Act
            using (unitOfWork.Start())
            {
                repository.Create(testModel01);
                repository.Create(testModel02);
                repository.Create(testModel03);

                unitOfWork.Commit();
            }

            // Assert
            using (unitOfWork.Start())
            {
                var foundModel = repository.Find.AllMatchingSpecification(TestModelSpecifications.TestPropertyStartsWithABC());

                Assert.That(!foundModel.Any());
            }
        }