public void Delete_DeletesPageTemplatesThatBelongToTheSectionTemplate()
        {
            //arrange
            var sectionTemplate = new SectionTemplate
            {
                Id            = 1,
                PageTemplates = new Collection <PageTemplate>
                {
                    new PageTemplate
                    {
                        Id = 99
                    }
                }
            };
            var sectionTemplateDbSet = new InMemoryDbSet <SectionTemplate> {
                sectionTemplate
            };
            var pageTemplateDbSet = new InMemoryDbSet <PageTemplate> {
                sectionTemplate.PageTemplates.First()
            };

            _dbContextMock.Setup(x => x.GetDbSet <SectionTemplate>()).Returns(sectionTemplateDbSet);
            _dbContextMock.Setup(x => x.GetDbSet <PageTemplate>()).Returns(pageTemplateDbSet);

            //act
            _sectionTemplateService.Delete(sectionTemplate.Id);

            //assert
            _pageTemplateServiceMock.Verify(x => x.Delete(sectionTemplate.PageTemplates.First(), false));
        }
        public void ReturnCorrectNumberOfPages_WhenNoRequestUserIdIsMatching(int itemsCount, int expectedPagesCount)
        {
            // Arrange
            var contextMock     = new Mock <ITravelGuideContext>();
            var userServiceMock = new Mock <IUserService>();
            var factoryMock     = new Mock <IRequestFactory>();

            var userId = "userId";

            var requestsMock = new InMemoryDbSet <Request>(true);

            for (int i = 0; i < itemsCount; i++)
            {
                requestsMock.Add(new Request());
            }

            contextMock.Setup(x => x.Requests).Returns(requestsMock);
            var service = new RequestService(contextMock.Object, userServiceMock.Object, factoryMock.Object);

            // Act
            var pagesCount = service.GetRequestsPagesCountForUser(userId, 3);

            // Assert
            Assert.AreEqual(expectedPagesCount, pagesCount);
        }
Ejemplo n.º 3
0
		public void FetchByPersonId()
		{
			// Arrange
			var generator = new RandomObjectGenerator();
			var expected = new E.Person
			{
				Id = generator.Generate<int>(),
				FirstName = generator.Generate<string>(),
				MiddleName = generator.Generate<string>(),
				LastName = generator.Generate<string>(),
				Gender = generator.Generate<string>()
			};

			var dbSet = new InMemoryDbSet<E.Person> { expected };

			PersonTests.Arrange(mockedContext =>
			{
				mockedContext.Setup(_ => _.People).Returns(dbSet);
				mockedContext.Setup(_ => _.Dispose());
			}, (() =>
			{
				// Act
				var expectedId = expected.Id;
				var actual = DataPortal.Fetch<Person>(expectedId);

				// Assert
				Assert.IsNotNull(actual);
				Assert.IsFalse(actual.IsNew, actual.GetPropertyName(_ => _.IsNew));
				Assert.AreEqual(expectedId, actual.Id, actual.GetPropertyName(_ => _.Id));
				Assert.AreEqual(expected.FirstName, actual.FirstName, actual.GetPropertyName(_ => _.FirstName));
				Assert.AreEqual(expected.MiddleName, actual.MiddleName, actual.GetPropertyName(_ => _.MiddleName));
				Assert.AreEqual(expected.LastName, actual.LastName, actual.GetPropertyName(_ => _.LastName));
				Assert.AreEqual(expected.Gender, actual.Gender, actual.GetPropertyName(_ => _.Gender));
			}));
		}
Ejemplo n.º 4
0
            public void ResponseContainsNewUUIDAndManageId()
            {
                Guid pollId = new Guid("00DB2F1B-C4F5-44D3-960C-386CEB9690C4");

                var existingPoll = new Poll()
                {
                    CreatorIdentity = UserId1, UUID = pollId
                };

                var dbPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    existingPoll
                };

                IContextFactory     mockContextFactory = CreateContextFactory(dbPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);

                var request = new CopyPollRequestModel()
                {
                    UUIDToCopy = pollId
                };


                CopyPollResponseModel response = controller.Copy(request);

                Poll copiedPoll = dbPolls.ToList()[1];

                Assert.AreEqual(copiedPoll.UUID, response.NewPollId);
                Assert.AreEqual(copiedPoll.ManageId, response.NewManageId);
            }
Ejemplo n.º 5
0
        public void GetAllTrashed_ReturnsOnlyTrashedNodes()
        {
            //arrange
            var sectionNodeDbSet = new InMemoryDbSet <SectionNode>
            {
                new SectionNode {
                    Id = 1, InTrash = true
                },
                new SectionNode {
                    Id = 2, InTrash = true
                },
                new SectionNode {
                    Id = 3, InTrash = false
                },
                new SectionNode {
                    Id = 4, InTrash = false
                }
            };

            _dbContextMock.Setup(x => x.GetDbSet <SectionNode>()).Returns(sectionNodeDbSet);

            //act
            var sectionNodes = _sectionNodeService.GetAllTrashed();

            //assert
            sectionNodes.ToList().ForEach(x => x.InTrash.Should().Be.True());
        }
Ejemplo n.º 6
0
        public void GetAll_IncludeTrashed_IncludesTrashedNodes()
        {
            //arrange
            var sectionNodeDbSet = new InMemoryDbSet <SectionNode>
            {
                new SectionNode {
                    Id = 1, InTrash = true
                },
                new SectionNode {
                    Id = 2, InTrash = true
                },
                new SectionNode {
                    Id = 3, InTrash = false
                },
                new SectionNode {
                    Id = 4, InTrash = false
                }
            };

            _dbContextMock.Setup(x => x.GetDbSet <SectionNode>()).Returns(sectionNodeDbSet);

            //act
            var sectionNodes = _sectionNodeService.GetAll(true);

            //assert
            sectionNodes.Count().Should().Equals(sectionNodeDbSet.Count());
        }
Ejemplo n.º 7
0
        public void ReturnCorrectNumberOfPages_WhenThereIsAQueryPresentAndAMatchInItemName(int itemsCount, int expectedPagesCount)
        {
            // Arrange
            var contextMock     = new Mock <ITravelGuideContext>();
            var userServiceMock = new Mock <IUserService>();
            var factoryMock     = new Mock <IRequestFactory>();

            var requestsMock = new InMemoryDbSet <Request>(true);

            for (int i = 0; i < itemsCount; i++)
            {
                requestsMock.Add(new Request()
                {
                    StoreItem = new StoreItem()
                    {
                        ItemName = "ass"
                    }, User = new User()
                    {
                        UserName = "******"
                    }, FirstName = "xxx", LastName = "svv", CreatedOn = DateTime.Now.AddSeconds(1)
                });
            }

            contextMock.Setup(x => x.Requests).Returns(requestsMock);
            var service = new RequestService(contextMock.Object, userServiceMock.Object, factoryMock.Object);

            string query    = "A";
            var    pageSize = 3;

            // Act
            var pagesCount = service.GetTotalPagesCount(query, pageSize);

            // Assert
            Assert.AreEqual(expectedPagesCount, pagesCount);
        }
        public void Fetch()
        {
            var person = EntityCreator.Create<E.Person>();
            var people = new InMemoryDbSet<E.Person> { person };
            var context = new Mock<IEntityContext>(MockBehavior.Strict);
            context.Setup(_ => _.People).Returns(people);
            context.Setup(_ => _.Dispose());

            var personViewFactory = new Mock<IObjectFactory<IPersonView>>(MockBehavior.Strict);
            personViewFactory
                .Setup(_ => _.FetchChild(It.Is<int>(__ => __ == person.Id)))
                .Returns(Mock.Of<IPersonView>());

            var container = new ContainerBuilder();
            container.Register<IEntityContext>(_ => context.Object);
            container.Register<IObjectFactory<IPersonView>>(_ => personViewFactory.Object);

            using (container.Build().Bind(() => IoC.Container))
            {
                var actual = DataPortal.Fetch<PersonCollectionView>();
                Assert.IsNotNull(actual);
                Assert.AreEqual(1, actual.Count, "Count");
            }

            context.VerifyAll();
            personViewFactory.VerifyAll();
        }
Ejemplo n.º 9
0
		public void Insert()
		{
			var generator = new RandomObjectGenerator();
			var optionPosition = generator.Generate<short>();
			var optionText = generator.Generate<string>();
			var pollId = generator.Generate<int>();
			var pollOptionId = generator.Generate<int>();

			var poll = new Mock<IPoll>();
			poll.Setup(_ => _.PollID).Returns(pollId);

			var pollOptions = new InMemoryDbSet<MVPollOption>();
			var entities = new Mock<IEntities>();
			entities.Setup(_ => _.MVPollOptions)
				.Returns(pollOptions);
			entities.Setup(_ => _.SaveChanges()).Callback(() => pollOptions.Local[0].PollOptionID = pollOptionId);
			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var pollOption = DataPortal.CreateChild<PollOption>();
				pollOption.OptionPosition = optionPosition;
				pollOption.OptionText = optionText;

				DataPortal.UpdateChild(pollOption, poll.Object);

				Assert.AreEqual(pollId, pollOption.PollID, pollOption.GetPropertyName(_ => _.PollID));
				Assert.AreEqual(pollOptionId, pollOption.PollOptionID, pollOption.GetPropertyName(_ => _.PollOptionID));
				Assert.AreEqual(optionPosition, pollOption.OptionPosition, pollOption.GetPropertyName(_ => _.OptionPosition));
				Assert.AreEqual(optionText, pollOption.OptionText, pollOption.GetPropertyName(_ => _.OptionText));
			}
		}
 /// <summary>
 /// Sets up the fake database.
 /// </summary>
 public FakeZooDbContext()
 {
     // We're setting our DbSets to be InMemoryDbSets rather than using SQL Server.
     Enclosures = new InMemoryDbSet<Enclosure> { FindFunction = (a, i) => a.FirstOrDefault(x => x.Id == i.Cast<int>().First()) };
     Animals = new InMemoryDbSet<Animal> { FindFunction = (a, i) => a.FirstOrDefault(x => x.Id == i.Cast<int>().First()) };
     Keepers = new InMemoryDbSet<Keeper> { FindFunction = (a, i) => a.FirstOrDefault(x => x.Id == i.Cast<int>().First()) };
 }
        public void ReturnNoRequests_WhenTheThereAreNoRequestsWithMatchingUserId(string wrongId)
        {
            // Arrange
            var contextMock     = new Mock <ITravelGuideContext>();
            var userServiceMock = new Mock <IUserService>();
            var factoryMock     = new Mock <IRequestFactory>();

            var userId = "userId";

            var requestWithIncorrectUserId = new Request()
            {
                UserId = wrongId
            };

            var requestsMock = new InMemoryDbSet <Request>(true)
            {
                requestWithIncorrectUserId, requestWithIncorrectUserId
            };

            contextMock.Setup(x => x.Requests).Returns(requestsMock);
            var service = new RequestService(contextMock.Object, userServiceMock.Object, factoryMock.Object);

            var page     = 1;
            var pageSize = 5;

            // Act
            var requests = service.GetRequestsForUser(userId, page, pageSize);

            // Assert
            Assert.AreEqual(0, requests.Count());
        }
Ejemplo n.º 12
0
            public void AddsNewPoll()
            {
                Guid pollId = new Guid("00DB2F1B-C4F5-44D3-960C-386CEB9690C4");

                var existingPoll = new Poll()
                {
                    CreatorIdentity = UserId1, UUID = pollId
                };

                var dbPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    existingPoll
                };

                IContextFactory     mockContextFactory = CreateContextFactory(dbPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);

                var request = new CopyPollRequestModel()
                {
                    UUIDToCopy = pollId
                };


                controller.Copy(request);

                Assert.AreEqual(2, dbPolls.Count());
            }
Ejemplo n.º 13
0
            public void UserWithPolls_ReturnsAllPolls()
            {
                var existingPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    new Poll()
                    {
                        CreatorIdentity = UserId1
                    },
                    new Poll()
                    {
                        CreatorIdentity = UserId1
                    },
                    new Poll()
                    {
                        CreatorIdentity = UserId1
                    }
                };

                IContextFactory     mockContextFactory = CreateContextFactory(existingPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);


                List <DashboardPollResponseModel> response = controller.Polls();


                Assert.AreEqual(3, response.Count);
            }
Ejemplo n.º 14
0
            public void UnknownPollToCopy_ThrowsBadRequestException()
            {
                Guid pollId        = new Guid("00DB2F1B-C4F5-44D3-960C-386CEB9690C4");
                Guid unknownPollId = new Guid("F5F5AF58-4190-4275-8178-FED76105F6BB");

                var existingPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    new Poll()
                    {
                        UUID = pollId
                    }
                };

                IContextFactory     mockContextFactory = CreateContextFactory(existingPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);

                var request = new CopyPollRequestModel()
                {
                    UUIDToCopy = unknownPollId
                };

                controller.Copy(request);
            }
        private static Mock <CommitFailureHandler> CreateCommitFailureHandlerMock()
        {
            Func <DbConnection, TransactionContext> transactionContextFactory =
                c =>
            {
                var transactionContextMock = new Mock <TransactionContext>(c)
                {
                    CallBase = true
                };
                var transactionRowSet = new InMemoryDbSet <TransactionRow>();
                transactionContextMock.Setup(m => m.Transactions).Returns(transactionRowSet);
                return(transactionContextMock.Object);
            };
            var handlerMock = new Mock <CommitFailureHandler>(transactionContextFactory)
            {
                CallBase = true
            };

            handlerMock.Protected().Setup("PruneTransactionHistory", ItExpr.IsAny <bool>(), ItExpr.IsAny <bool>()).Callback(() => { });
#if !NET40
            handlerMock.Protected()
            .Setup <Task>("PruneTransactionHistoryAsync", ItExpr.IsAny <bool>(), ItExpr.IsAny <bool>(), ItExpr.IsAny <CancellationToken>())
            .Returns(() => Task.FromResult(true));
#endif
            return(handlerMock);
        }
Ejemplo n.º 16
0
        public void In_memory_DbSet_can_be_used_for_AddOrUpdate()
        {
            DbSet<Product> set = new InMemoryDbSet<Product>();

            set.AddOrUpdate(new[] { new Product { Id = 1 }, new Product { Id = 2 } });

            Assert.Equal(new[] { 1, 2 }, set.Select(p => p.Id).OrderBy(i => i));
        }
Ejemplo n.º 17
0
        public void In_memory_DbSet_can_be_used_for_RemoveRange()
        {
            var products = new[] { new Product(), new Product() };
            var set = new InMemoryDbSet<Product>(products);

            Assert.Same(products, set.RemoveRange(products));
            Assert.Empty(set);
        }
Ejemplo n.º 18
0
        public void In_memory_DbSet_can_be_used_for_Attach()
        {
            var set = new InMemoryDbSet<Product>();
            var product = new Product();

            Assert.Same(product, set.Attach(product));
            Assert.Same(product, set.Single());
        }
Ejemplo n.º 19
0
        public void In_memory_DbSet_can_be_used_for_AddRange()
        {
            var set = new InMemoryDbSet<Product>();
            var products = new[] { new Product { Id = 1 }, new Product { Id = 2 } };

            Assert.Same(products, set.AddRange(products));
            Assert.Equal(products.OrderBy(p => p.Id), set.OrderBy(p => p.Id));
        }
Ejemplo n.º 20
0
            public void CopiedPollHasSameValuesAsOriginal()
            {
                Guid           pollId        = new Guid("00DB2F1B-C4F5-44D3-960C-386CEB9690C4");
                const string   creator       = "Someone";
                const PollType pollType      = PollType.UpDown;
                const int      maxPoints     = 9;
                const int      maxPerVote    = 2;
                const bool     inviteOnly    = true;
                const bool     namedVoting   = true;
                DateTime?      expiryDateUtc = new DateTime(2015, 6, 2, 14, 2, 56, DateTimeKind.Utc);
                const bool     optionAdding  = true;

                var existingPoll = new Poll()
                {
                    UUID            = pollId,
                    Creator         = creator,
                    CreatorIdentity = UserId1,
                    PollType        = pollType,
                    MaxPoints       = maxPoints,
                    MaxPerVote      = maxPerVote,
                    InviteOnly      = inviteOnly,
                    NamedVoting     = namedVoting,
                    ExpiryDateUtc   = expiryDateUtc,
                    ChoiceAdding    = optionAdding
                };

                var dbPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true)
                {
                    existingPoll
                };

                IContextFactory     mockContextFactory = CreateContextFactory(dbPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);

                var request = new CopyPollRequestModel()
                {
                    UUIDToCopy = pollId
                };


                controller.Copy(request);

                List <Poll> polls      = dbPolls.ToList();
                Poll        copiedPoll = polls[1];


                Assert.AreEqual(creator, copiedPoll.Creator);
                Assert.AreEqual(UserId1, copiedPoll.CreatorIdentity);
                Assert.AreEqual(pollType, copiedPoll.PollType);
                Assert.AreEqual(maxPoints, copiedPoll.MaxPoints);
                Assert.AreEqual(maxPerVote, copiedPoll.MaxPerVote);
                Assert.AreEqual(inviteOnly, copiedPoll.InviteOnly);
                Assert.AreEqual(namedVoting, copiedPoll.NamedVoting);
                Assert.AreEqual(expiryDateUtc, copiedPoll.ExpiryDateUtc);
                Assert.AreEqual(optionAdding, copiedPoll.ChoiceAdding);
            }
 public FakeHypermartContext()
 {
     // We're setting our DbSets to be InMemoryDbSets rather than using SQL Server.
     Files = new InMemoryDbSet<File> { FindFunction = (a, i) => a.FirstOrDefault(x => x.ID == i.Cast<int>().First()) };
     Platforms = new InMemoryDbSet<Platform>();//{ FindFunction = (a, i) => a.FirstOrDefault(x => x.ID == i.Cast<int>().First()) };
     Products = new InMemoryDbSet<Product> { FindFunction = (a, i) => a.FirstOrDefault(x => x.ID == i.Cast<int>().First()) };
     Screenshots = new InMemoryDbSet<Screenshot> { FindFunction = (a, i) => a.FirstOrDefault(x => x.ID == i.Cast<int>().First()) };
     Ratings = new InMemoryDbSet<Rating> ();
 }
        public void SetUp()
        {
            _contextMock    = new Mock <IGoProShopContext>();
            _customersDbSet = new InMemoryDbSet <Customer>();

            _contextMock.Setup(x => x.Customers).Returns(_customersDbSet);
            _contextMock.Setup(x => x.Set <Customer>()).Returns(_customersDbSet);
            _baseRepository = new BaseRepository <Customer>(_contextMock.Object);
        }
 public InMemoryMetricsStore()
 {
     Builds = new InMemoryDbSet<Build>();
     Targets = new InMemoryDbSet<Target>();
     Modules = new InMemoryDbSet<Module>();
     Namespaces = new InMemoryDbSet<Namespace>();
     CodeTypes = new InMemoryDbSet<CodeType>();
     CodeMembers = new InMemoryDbSet<CodeMember>();
 }
Ejemplo n.º 24
0
        public void Insert()
        {
            var generator        = new RandomObjectGenerator();
            var birthDate        = generator.Generate <DateTime>();
            var emailAddress     = generator.Generate <string>();
            var firstName        = generator.Generate <string>();
            var gender           = generator.Generate <string>();
            var lastName         = generator.Generate <string>();
            var postalCode       = generator.Generate <string>();
            var profileAuthToken = generator.Generate <string>();
            var profileId        = generator.Generate <string>();
            var userId           = generator.Generate <int>();
            var userName         = generator.Generate <string>();
            var userRoleId       = generator.Generate <int>();

            var users    = new InMemoryDbSet <MVUser>();
            var entities = new Mock <IEntities>(MockBehavior.Strict);

            entities.Setup(_ => _.MVUsers)
            .Returns(users);
            entities.Setup(_ => _.SaveChanges()).Callback(() => users.Local[0].UserID = userId)
            .Returns(1);
            entities.Setup(_ => _.Dispose());

            var builder = new ContainerBuilder();

            builder.Register <IEntities>(_ => entities.Object);

            using (new ObjectActivator(builder.Build(), new ActivatorCallContext())
                   .Bind(() => ApplicationContext.DataPortalActivator))
            {
                var user = new DataPortal <User>().Create(profileId);
                user.BirthDate        = birthDate;
                user.EmailAddress     = emailAddress;
                user.FirstName        = firstName;
                user.Gender           = gender;
                user.LastName         = lastName;
                user.PostalCode       = postalCode;
                user.ProfileAuthToken = profileAuthToken;
                user.UserName         = userName;
                user.UserRoleID       = userRoleId;
                user = user.Save();

                Assert.AreEqual(birthDate, user.BirthDate, nameof(user.BirthDate));
                Assert.AreEqual(emailAddress, user.EmailAddress, nameof(user.EmailAddress));
                Assert.AreEqual(firstName, user.FirstName, nameof(user.FirstName));
                Assert.AreEqual(gender, user.Gender, nameof(user.Gender));
                Assert.AreEqual(lastName, user.LastName, nameof(user.LastName));
                Assert.AreEqual(postalCode, user.PostalCode, nameof(user.PostalCode));
                Assert.AreEqual(profileAuthToken, user.ProfileAuthToken, nameof(user.ProfileAuthToken));
                Assert.AreEqual(userId, user.UserID, nameof(user.UserID));
                Assert.AreEqual(userName, user.UserName, nameof(user.UserName));
                Assert.AreEqual(userRoleId, user.UserRoleID, nameof(user.UserRoleID));
            }

            entities.VerifyAll();
        }
Ejemplo n.º 25
0
        public void In_memory_DbSet_can_be_used_for_Find()
        {
            var product = new Product { Id = 1 };
            var set = new InMemoryDbSet<Product>(
                new[] { product, new Product { Id = 2 } },
                (d, k) => d.Single(p => p.Id == (int)k[0]));

            Assert.Same(product, set.Find(1));
        }
Ejemplo n.º 26
0
        public void In_memory_DbSet_can_be_used_for_Remove()
        {
            var set = new InMemoryDbSet<Product>();
            var product = new Product();

            set.Add(product);

            Assert.Same(product, set.Remove(product));
            Assert.Empty(set);
        }
        public void OnStart()
        {
            var mockClients = new InMemoryDbSet <Client>()
            {
                new Client()
                {
                    Id = 1
                }
            };

            dbMock.Setup(db => db.Clients).Returns(mockClients);
        }
Ejemplo n.º 28
0
            public void NoCopyPollRequest_ThrowsBadRequestException()
            {
                var existingPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true);

                IContextFactory     mockContextFactory = CreateContextFactory(existingPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);


                controller.Copy(null);
            }
        public void GetResponderEmails_EmptyRoster()
        {
            var responders = new InMemoryDbSet<MissionRoster>();

              var dataMock = new Mock<IKcsarContext>();
              dataMock.SetupGet(f => f.MissionRosters).Returns(responders);

              var controller = new MissionsController(dataMock.Object, new AlwaysYesAuth(), new ConsoleLogger());

              var result = controller.GetResponderEmails(Guid.NewGuid(), null);
              Assert.IsEmpty(result);
        }
Ejemplo n.º 30
0
 public MockDb()
 {
     UserList = new InMemoryDbSet<User>();
     Groups = new InMemoryDbSet<Group>();
     Events = new InMemoryDbSet<Event>();
     Comments = new InMemoryDbSet<Comment>();
     GroupToUserRelations = new InMemoryDbSet<GroupToUserRelation>();
     GroupToEventRelations = new InMemoryDbSet<GroupToEventRelation>();
     UserToUserRelations = new InMemoryDbSet<UserToUserRelation>();
     EventToUserRelations = new InMemoryDbSet<EventToUserRelation>();
     EventToCommentRelations = new InMemoryDbSet<EventToCommentRelation>();
 }
Ejemplo n.º 31
0
        public void Insert()
        {
            var generator       = new RandomObjectGenerator();
            var userId          = generator.Generate <int>();
            var pollId          = generator.Generate <int>();
            var parentCommentId = generator.Generate <int>();
            var pollCommentId   = generator.Generate <int>();
            var userName        = generator.Generate <string>();
            var commentText     = generator.Generate <string>();

            var pollComments        = new Mock <IChildUpdate>(MockBehavior.Loose).As <IPollCommentCollection>();
            var pollCommentsFactory = new Mock <IObjectFactory <IPollCommentCollection> >(MockBehavior.Strict);

            pollCommentsFactory.Setup(_ => _.CreateChild()).Returns(pollComments.Object);

            var pollCommentFactory = Mock.Of <IObjectFactory <IPollComment> >();

            var entities        = new Mock <IEntities>(MockBehavior.Strict);
            var commentEntities = new InMemoryDbSet <MVPollComment>();

            entities.Setup(_ => _.MVPollComments).Returns(commentEntities);
            entities.Setup(_ => _.SaveChanges())
            .Callback(() => commentEntities.Local[0].PollCommentID = pollCommentId)
            .Returns(1);
            entities.Setup(_ => _.Dispose());

            var builder = new ContainerBuilder();

            builder.Register <IObjectFactory <IPollComment> >(_ => pollCommentFactory);
            builder.Register <IObjectFactory <IPollCommentCollection> >(_ => pollCommentsFactory.Object);
            builder.Register <IEntities>(_ => entities.Object);

            using (new ObjectActivator(builder.Build(), new ActivatorCallContext())
                   .Bind(() => ApplicationContext.DataPortalActivator))
            {
                var result = DataPortal.CreateChild <PollComment>(userId, userName);
                result.CommentText = commentText;
                DataPortal.UpdateChild(result, pollId, new int?(parentCommentId));
                Assert.AreEqual(commentText, result.CommentText);
                Assert.AreEqual(pollCommentId, result.PollCommentID);

                var savedEntity = commentEntities.Local[0];

                Assert.IsNotNull(savedEntity.CommentDate);
                Assert.AreEqual(userId, savedEntity.UserID);
                Assert.AreEqual(pollId, savedEntity.PollID);
                Assert.AreEqual(parentCommentId, savedEntity.ParentCommentID.Value);
                Assert.AreEqual(commentText, savedEntity.CommentText);
            }

            pollCommentsFactory.VerifyAll();
        }
Ejemplo n.º 32
0
        public void setup()
        {
            _redChoice = new Choice()
            {
                Name = "Red"
            };

            UUIDs     = new[] { Guid.NewGuid(), Guid.NewGuid(), _templateUUID, Guid.NewGuid() };
            _mainPoll = new Poll()
            {
                UUID = UUIDs[0], ManageId = Guid.NewGuid()
            };
            _otherPoll = new Poll()
            {
                UUID = UUIDs[1], ManageId = Guid.NewGuid()
            };

            _templateUUID        = Guid.NewGuid();
            _templateCreatedDate = DateTime.UtcNow.AddDays(-5);
            _templatePoll        = new Poll()
            {
                UUID           = _templateUUID,
                ManageId       = Guid.NewGuid(),
                CreatedDateUtc = _templateCreatedDate,
                Choices        = new List <Choice>()
                {
                    _redChoice
                },
                CreatorIdentity = UserId
            };

            _dummyPolls = new InMemoryDbSet <Poll>(true)
            {
                _mainPoll, _otherPoll, _templatePoll
            };

            var mockContextFactory = new Mock <IContextFactory>();
            var mockContext        = new Mock <IVotingContext>();

            mockContextFactory.Setup(a => a.CreateContext()).Returns(mockContext.Object);
            mockContext.Setup(a => a.Polls).Returns(_dummyPolls);
            mockContext.Setup(a => a.SaveChanges()).Callback(SaveChanges);

            _metricHandler = new Mock <IMetricHandler>();

            _controller = new PollController(mockContextFactory.Object, _metricHandler.Object, new Mock <ICorrespondenceService>().Object)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };
        }
        private static Mock<IDatabase> CreateDatabaseMock()
        {
            var database = new Mock<IDatabase>();

            var tasks = new InMemoryDbSet<TaskItem>();
            tasks.SetPrimaryKeyField(x => x.Id);
            database.SetupGet(x => x.TaskItems).Returns(tasks);

            var users = new InMemoryDbSet<User>();
            users.SetPrimaryKeyField(x => x.Id);
            database.SetupGet(x => x.Users).Returns(users);

            return database;
        }
Ejemplo n.º 34
0
        public void TestInitialize()
        {
            lifetimeScope = new Mock<ILifetimeScope>();
            dipsDbContext = new Mock<IDipsDbContext>();
            exchangePublisher = new Mock<IExchangePublisher<GetVouchersInformationRequest>>();
            transaction = new Mock<IDipsDbContextTransaction>();
            logger = new Mock<ILogger>();
            adapterConfiguration = new Mock<IAdapterConfiguration>();

            Log.Logger = logger.Object;

            queues = new InMemoryDbSet<DipsQueue>(true);
            dipsRequests = new InMemoryDbSet<DipsRequest>(true);
        }
Ejemplo n.º 35
0
        public void TestInitialize()
        {
            lifetimeScope        = new Mock <ILifetimeScope>();
            dipsDbContext        = new Mock <IDipsDbContext>();
            exchangePublisher    = new Mock <IExchangePublisher <CheckThirdPartyBatchResponse> >();
            transaction          = new Mock <IDipsDbContextTransaction>();
            logger               = new Mock <ILogger>();
            adapterConfiguration = new Mock <IAdapterConfiguration>();

            Log.Logger = logger.Object;

            queues   = new InMemoryDbSet <DipsQueue>(true);
            vouchers = new InMemoryDbSet <DipsNabChq>(true);
        }
        public void GetResponderEmails_EmptyRoster()
        {
            var responders = new InMemoryDbSet <MissionRoster>();

            var dataMock = new Mock <IKcsarContext>();

            dataMock.SetupGet(f => f.MissionRosters).Returns(responders);

            var controller = new MissionsController(dataMock.Object, new AlwaysYesAuth(), new ConsoleLogger());

            var result = controller.GetResponderEmails(Guid.NewGuid(), null);

            Assert.IsEmpty(result);
        }
        public void TestInitialize()
        {
            lifetimeScope = new Mock<ILifetimeScope>();
            dipsDbContext = new Mock<IDipsDbContext>();
            exchangePublisher = new Mock<IExchangePublisher<GenerateCorrespondingVoucherResponse>>();
            transaction = new Mock<IDipsDbContextTransaction>();
            logger = new Mock<ILogger>();
            adapterConfiguration = new Mock<IAdapterConfiguration>();

            Log.Logger = logger.Object;

            queues = new InMemoryDbSet<DipsQueue>(true);
            vouchers = new InMemoryDbSet<DipsNabChq>(true);
        }
        public void AddBoard()
        {
            // Arrange
            var stubBoards = new InMemoryDbSet<Board>();
            var board = new Board() { Model = new BoardModel { Name = "Dummy" }, Volume = 1 };
            stubEntities.Boards = stubBoards;

            // Act
            var sut = new EquipmentRepository(stubEntities, stubLogger);
            sut.AddBoard(board);

            // Assert
            Assert.AreEqual(1, stubBoards.Count(), "Boards count incorrect");
        }
        public void AddManufacturer()
        {
            // Arrange
            var stubManufacturers = new InMemoryDbSet<Manufacturer>();
            var manufacturer = new Manufacturer() { Name = "Dummy" };
            stubEntities.Manufacturers = stubManufacturers;

            // Act
            var sut = new EquipmentRepository(stubEntities, stubLogger);
            sut.AddManufacturer(manufacturer);

            // Assert
            Assert.AreEqual(1, stubManufacturers.Count(), "Manufacturers count incorrect");
        }
        public void AddSail()
        {
            // Arrange
            var stubSails = new InMemoryDbSet<Sail>();
            var sail = new Sail() { Model = new SailModel { Name = "Dummy" }, Size = 4.7 };
            stubEntities.Sails = stubSails;

            // Act
            var sut = new EquipmentRepository(stubEntities, stubLogger);
            sut.AddSail(sail);

            // Assert
            Assert.AreEqual(1, stubSails.Count(), "Sails count incorrect");
        }
Ejemplo n.º 41
0
		public void Insert()
		{
			var generator = new RandomObjectGenerator();
			var birthDate = generator.Generate<DateTime>();
			var emailAddress = generator.Generate<string>();
			var firstName = generator.Generate<string>();
			var gender = generator.Generate<string>();
			var lastName = generator.Generate<string>();
			var postalCode = generator.Generate<string>();
			var profileAuthToken = generator.Generate<string>();
			var profileId = generator.Generate<string>();
			var userId = generator.Generate<int>();
			var userName = generator.Generate<string>();
			var userRoleId = generator.Generate<int>();

			var users = new InMemoryDbSet<MVUser>();
			var entities = new Mock<IEntities>();
			entities.Setup(_ => _.MVUsers)
				.Returns(users);
			entities.Setup(_ => _.SaveChanges()).Callback(() => users.Local[0].UserID = userId);
			var builder = new ContainerBuilder();
			builder.Register<IEntities>(_ => entities.Object);

			using (new ObjectActivator(builder.Build()).Bind(() => ApplicationContext.DataPortalActivator))
			{
				var user = new DataPortal<User>().Create(profileId);
				user.BirthDate = birthDate;
				user.EmailAddress = emailAddress;
				user.FirstName = firstName;
				user.Gender = gender;
				user.LastName = lastName;
				user.PostalCode = postalCode;
				user.ProfileAuthToken = profileAuthToken;
				user.UserName = userName;
				user.UserRoleID = userRoleId;
				user = user.Save();

				Assert.AreEqual(birthDate, user.BirthDate, user.GetPropertyName(_ => _.BirthDate));
				Assert.AreEqual(emailAddress, user.EmailAddress, user.GetPropertyName(_ => _.EmailAddress));
				Assert.AreEqual(firstName, user.FirstName, user.GetPropertyName(_ => _.FirstName));
				Assert.AreEqual(gender, user.Gender, user.GetPropertyName(_ => _.Gender));
				Assert.AreEqual(lastName, user.LastName, user.GetPropertyName(_ => _.LastName));
				Assert.AreEqual(postalCode, user.PostalCode, user.GetPropertyName(_ => _.PostalCode));
				Assert.AreEqual(profileAuthToken, user.ProfileAuthToken, user.GetPropertyName(_ => _.ProfileAuthToken));
				Assert.AreEqual(userId, user.UserID, user.GetPropertyName(_ => _.UserID));
				Assert.AreEqual(userName, user.UserName, user.GetPropertyName(_ => _.UserName));
				Assert.AreEqual(userRoleId, user.UserRoleID, user.GetPropertyName(_ => _.UserRoleID));
			}
		}
Ejemplo n.º 42
0
            public void UserWithNoPolls_ReturnsEmptyPollList()
            {
                var existingPolls = new InMemoryDbSet <Poll>(clearDownExistingData: true);

                IContextFactory     mockContextFactory = CreateContextFactory(existingPolls);
                DashboardController controller         = CreateDashboardController(mockContextFactory);

                controller.User = CreateAuthenticatedUser(UserId1);


                List <DashboardPollResponseModel> response = controller.Polls();


                CollectionAssert.AreEquivalent(new List <Poll>(), response);
            }
Ejemplo n.º 43
0
        /// <summary>
        /// Registers a set of data.
        /// </summary>
        /// <typeparam name="T">The entity type to register set.</typeparam>
        /// <returns>The action object.</returns>
        public ITestAction UseRegisterTestDbSet <T>() where T : class, new()
        {
            InMemoryDbSet <T> eventSet = new InMemoryDbSet <T>();

            if (!registeredSets.ContainsKey(typeof(T).Name))
            {
                registeredSets.Add(typeof(T).Name, eventSet);

                ShimDbContext.AllInstances.SetOf1 <T>((p) =>
                {
                    return(registeredSets[typeof(T).Name] as DbSet <T>);
                });
            }
            return(this);
        }
 public FakeHypermartContext()
 {
     // We're setting our DbSets to be InMemoryDbSets rather than using SQL Server.
     Files = new InMemoryDbSet <File> {
         FindFunction = (a, i) => a.FirstOrDefault(x => x.ID == i.Cast <int>().First())
     };
     Platforms = new InMemoryDbSet <Platform>();//{ FindFunction = (a, i) => a.FirstOrDefault(x => x.ID == i.Cast<int>().First()) };
     Products  = new InMemoryDbSet <Product> {
         FindFunction = (a, i) => a.FirstOrDefault(x => x.ID == i.Cast <int>().First())
     };
     Screenshots = new InMemoryDbSet <Screenshot> {
         FindFunction = (a, i) => a.FirstOrDefault(x => x.ID == i.Cast <int>().First())
     };
     Ratings = new InMemoryDbSet <Rating> ();
 }
Ejemplo n.º 45
0
        public void TestInitialize()
        {
            lifetimeScope = new Mock <ILifetimeScope>();
            dipsDbContext = new Mock <IDipsDbContext>();
            transaction   = new Mock <IDipsDbContextTransaction>();
            logger        = new Mock <ILogger>();

            Log.Logger = logger.Object;

            dipsQueueSet    = new InMemoryDbSet <DipsQueue>(true);
            dipsNabChqSet   = new InMemoryDbSet <DipsNabChq>(true);
            dipsDbIndexSet  = new InMemoryDbSet <DipsDbIndex>(true);
            dipsResponseSet = new InMemoryDbSet <DipsResponseDone>();

            InitializeTestData();
        }
        public void Init()
        {
            var klaus = new Gutachter { Id= 2, Vorname = "Klaus"};
            klaus.Gutachten.Add(new Gutachten());

            _inMemoryDbSet = new InMemoryDbSet<Gutachter>(true)
                             {
                                 new Gutachter { Id = 1, Vorname = "Hans" },
                                 klaus,
                                 new Gutachter { Id = 3, Vorname = "Inge" }
                             };

            _mockedContext = new Mock<IDashboardContext>();
            _mockedContext.Setup(x => x.Gutachter).Returns(_inMemoryDbSet);
            _sut = new GutachterRepository(_mockedContext.Object);
        }
Ejemplo n.º 47
0
        public async Task GetAllUsers_ReturnsOk()
        {
            //Arrange 
            var mockUsers = new InMemoryDbSet<User> { new User { UserName = "******" }, new User() };
            _dbContextMock
                .Setup(x => x.Users)
                .Returns(mockUsers);

            //Act
            IHttpActionResult result = await _controller.Get();
            var ok = result as OkNegotiatedContentResult<System.Data.Entity.IDbSet<User>>;

            //Assert
            Assert.IsNotNull(ok);
            Assert.IsTrue(ok.Content.Count() == 2);
        }
        public void TestInitialize()
        {
            lifetimeScope = new Mock<ILifetimeScope>();
            dipsDbContext = new Mock<IDipsDbContext>();
            transaction = new Mock<IDipsDbContextTransaction>();
            logger = new Mock<ILogger>();
      
            Log.Logger = logger.Object;

            dipsQueueSet = new InMemoryDbSet<DipsQueue>(true);
            dipsNabChqSet = new InMemoryDbSet<DipsNabChq>(true);
            dipsDbIndexSet = new InMemoryDbSet<DipsDbIndex>(true);
            dipsResponseSet = new InMemoryDbSet<DipsResponseDone>();

            InitializeTestData();
        }
Ejemplo n.º 49
0
        public void ShouldFilterTheBillsForTheGivenUser()
        {
            var billContext         = MockRepository.GenerateMock <IBillContext>();
            var now                 = DateTime.Now;
            var billModelForUser102 = new BillModel {
                UserId = 102, Id = 2, StartFrom = now.AddYears(-13), Repeat = new Repetition {
                    RecurrenceNumber = 1, RecurrenceUnit = "Year"
                }
            };
            var bills = new InMemoryDbSet <BillModel>
            {
                new BillModel {
                    UserId = 101, Id = 1, StartFrom = now.AddYears(-10), Repeat = new Repetition {
                        RecurrenceNumber = 1, RecurrenceUnit = "Year"
                    }
                },
                billModelForUser102,
                new BillModel {
                    UserId = 103, Id = 3, StartFrom = now.AddYears(-12), Repeat = new Repetition {
                        RecurrenceNumber = 1, RecurrenceUnit = "Year"
                    }
                },
            };

            billContext.Stub(c => c.Bills).Return(bills);

            var scheduleFilters        = MockRepository.GenerateMock <IScheduleFilters>();
            var paymentScheduleService = new PaymentScheduleService(billContext, scheduleFilters);

            var scheduleRequest = new ScheduleRequest
            {
                StartDate = DateTime.Now.AddDays(-10),
                EndDate   = DateTime.Now.AddDays(10),
                UserId    = 102
            };

            var filteredBills = new List <BillModel> {
                billModelForUser102
            };

            scheduleFilters.Stub(f => f.Filter(
                                     Arg <IEnumerable <BillModel> > .Matches(b => b.MatchesAll(m => m.UserId == 102)), Arg <ScheduleRequest> .Is.Equal(scheduleRequest))).Return(filteredBills);

            var summaryOfDues = paymentScheduleService.GetSummaryOfDues(scheduleRequest);

            Assert.That(summaryOfDues.Bills, Is.EqualTo(filteredBills));
        }
Ejemplo n.º 50
0
        public PersonControllerTests()
        {
            _persons   = new InMemoryDbSet <Person>();
            _interests = new InMemoryDbSet <PersonInterest>();
            _images    = new InMemoryDbSet <PersonImage>();

            for (int i = 1; i < 31; i++)
            {
                var newPerson = new Person
                {
                    Id          = i,
                    DateOfBirth = new DateTime(1990, 1, i),
                    FirstName   = $"First{i}",
                    LastName    = $"last{i}",
                    Image       = new PersonImage {
                        PersonId = i, ImageBase64 = i.ToString()
                    },
                    Interests = new List <PersonInterest>(),
                };
                for (int j = 1; j < i / 2; j++)
                {
                    var newInterst = new PersonInterest {
                        Id = i ^ j, Interest = $"Interest{i}_{j}", PersonId = i, Person = newPerson
                    };
                    newPerson.Interests.Add(newInterst);
                    _interests.Add(newInterst);
                }
                if (i == 10 || i == 11)
                {
                    var snowboardingInterest = new PersonInterest {
                        Id = 1000 + i, Interest = "Snowboarding", PersonId = i, Person = newPerson
                    };
                    newPerson.Interests.Add(snowboardingInterest);
                    _interests.Add(snowboardingInterest);
                }

                _images.Add(newPerson.Image);
                _persons.Add(newPerson);
            }

            _mockContext = new Mock <PeopleSearchContext>();
            _mockContext.Setup(x => x.People).Returns(_persons);
            _mockContext.Setup(x => x.Interests).Returns(_interests);
            _mockContext.Setup(x => x.PersonImages).Returns(_images);

            _personRepository = new PersonRepository(_mockContext.Object);
        }
Ejemplo n.º 51
0
        public void AddEntityToDbSetWhenCallCreate()
        {
            var entities      = new List <ReaderShould.Entity>();
            var inMemoryDbSet = new InMemoryDbSet <ReaderShould.Entity>(entities);
            var mockedContext = new Mock <IDbContext>();

            mockedContext.Setup(context => context.Set <ReaderShould.Entity>())
            .Returns(inMemoryDbSet);
            using var writer = new Writer(mockedContext.Object);

            var newEntity = new ReaderShould.Entity();

            writer.Create(newEntity);

            entities.Should().ContainSingle();
            entities.First().Should().Be(newEntity);
        }
Ejemplo n.º 52
0
        public void Setup()
        {
            _dummyPolls = new InMemoryDbSet <Poll>(true);

            var mockContextFactory = new Mock <IContextFactory>();
            var mockContext        = new Mock <IVotingContext>();

            _mockContext = mockContext.Object;
            mockContextFactory.Setup(a => a.CreateContext()).Returns(_mockContext);
            mockContext.Setup(a => a.Polls).Returns(_dummyPolls);

            var mockMetricHandler = new Mock <IMetricHandler>();

            _controller               = new WebApiController(mockContextFactory.Object, mockMetricHandler.Object);
            _controller.Request       = new HttpRequestMessage();
            _controller.Configuration = new HttpConfiguration();
        }
        public void ReturnAnEmptyCollection_WhenThereAreNoRequests()
        {
            // Arrange
            var contextMock     = new Mock <ITravelGuideContext>();
            var userServiceMock = new Mock <IUserService>();
            var factoryMock     = new Mock <IRequestFactory>();
            var requestsMock    = new InMemoryDbSet <Request>(true);

            contextMock.Setup(x => x.Requests).Returns(requestsMock);
            var service = new RequestService(contextMock.Object, userServiceMock.Object, factoryMock.Object);

            // Act
            var requests = service.GetAllRequests();

            // Assert
            Assert.AreEqual(0, requests.Count());
        }
        public void TestInitialize()
        {
            lifetimeScope = new Mock<ILifetimeScope>();
            dipsDbContext = new Mock<IDipsDbContext>();
            dipsQueueMapper = new Mock<IMapper<CorrectBatchCodelineRequest, DipsQueue>>();
            dipsVoucherMapper = new Mock<IMapper<CorrectBatchCodelineRequest, IEnumerable<DipsNabChq>>>();
            dipsDbIndexMapper = new Mock<IMapper<CorrectBatchCodelineRequest, IEnumerable<DipsDbIndex>>>();
            transaction = new Mock<IDipsDbContextTransaction>();
            logger = new Mock<ILogger>();
            imageMergeHelper = new Mock<IImageMergeHelper>();
            adapterConfiguration = new Mock<IAdapterConfiguration>();

            Log.Logger = logger.Object;

            dipsQueueSet = new InMemoryDbSet<DipsQueue>(true);
            dipsNabChqSet = new InMemoryDbSet<DipsNabChq>(true);
            dipsDbIndexSet = new InMemoryDbSet<DipsDbIndex>(true);
        }
Ejemplo n.º 55
0
		public void FetchById()
		{
			var generator = new RandomObjectGenerator();
			var id = generator.Generate<int>();
			var products = new InMemoryDbSet<E.Product> { EntityCreator.Create<E.Product>(_ => { _.Id = id; }) };
			var context = new Mock<IEntityContext>(MockBehavior.Strict);
			context.Setup(_ => _.Products).Returns(products);
			context.Setup(_ => _.Dispose());
			var container = new ContainerBuilder();
			container.Register<IEntityContext>(_ => context.Object);
			using (container.Build().Bind(() => IoC.Container))
			{
				var actual = DataPortal.Fetch<Product>(id);
				Assert.AreEqual(id, actual.Id, actual.GetPropertyName(_ => _.Id));

				context.VerifyAll();
			}
		}
        public void GivenATrelloBoardMemberWhenPersistingTeamMembers()
        {
            _trelloBoardMember = new BoardMember
            {
                Id = Guid.NewGuid().ToString()
            };

            _mockTeamMembers = new InMemoryDbSet<TeamMember>();

            _mockHackTrackDbContext = new Mock<IHackTrackDbContext>();
            _mockHackTrackDbContext
                .SetupGet(context => context.TeamMembers)
                .Returns(_mockTeamMembers);
            _mockHackTrackDbContext
                .Setup(context => context.SaveChanges());

            var service = new TrelloMemberPersistenceService(_mockHackTrackDbContext.Object);
            service.PersistMember(_trelloBoardMember);
        }
        public void TestInitialize()
        {
            lifetimeScope = new Mock<ILifetimeScope>();
            dipsDbContext = new Mock<IDipsDbContext>();
            dipsQueueMapper = new Mock<IMapper<GenerateCorrespondingVoucherRequest, DipsQueue>>();
            dipsVoucherMapper = new Mock<IMapper<GenerateCorrespondingVoucherRequest, IEnumerable<DipsNabChq>>>();
            dipsDbIndexMapper = new Mock<IMapper<GenerateCorrespondingVoucherRequest, IEnumerable<DipsDbIndex>>>();
            transaction = new Mock<IDipsDbContextTransaction>();
            logger = new Mock<ILogger>();
            adapterConfiguration = new Mock<IAdapterConfiguration>();

            Log.Logger = logger.Object;

            dipsQueueSet = new InMemoryDbSet<DipsQueue>(true);
            dipsNabChqSet = new InMemoryDbSet<DipsNabChq>(true);
            dipsDbIndexSet = new InMemoryDbSet<DipsDbIndex>(true);

            InitializeTestData();
        }
        public void TestInitialize()
        {
            lifetimeScope = new Mock<ILifetimeScope>();
            dipsDbContext = new Mock<IDipsDbContext>();
            dipsQueueMapper = new Mock<IMapper<VoucherInformation[], DipsQueue>>();
            dipsVoucherMapper = new Mock<IMapper<VoucherInformation[], IEnumerable<DipsNabChq>>>();
            dipsDbIndexMapper = new Mock<IMapper<VoucherInformation[], IEnumerable<DipsDbIndex>>>();
            transaction = new Mock<IDipsDbContextTransaction>();
            logger = new Mock<ILogger>();
            adapterConfiguration = new Mock<IAdapterConfiguration>();
            scannedBatchHelper = new Mock<IScannedBatchHelper>();

            Log.Logger = logger.Object;

            dipsQueueSet = new InMemoryDbSet<DipsQueue>(true);
            dipsNabChqSet = new InMemoryDbSet<DipsNabChq>(true);
            dipsDbIndexSet = new InMemoryDbSet<DipsDbIndex>(true);

            InitializeTestData();
        }
            public void ReturnsActiveWorkItemWhenAWorkerHasNoCompletedDate()
            {
                var job = new Mock<IJob>();
                job.Setup(j => j.Name).Returns("docoolstuffjobname");
                var workItems = new InMemoryDbSet<WorkItem>
                {
                    new WorkItem
                    {
                        JobName = job.Object.Name,
                        Started = DateTime.UtcNow,
                        Completed = null
                    }
                };
                var context = new Mock<WorkItemsContext>();
                context.Object.WorkItems = workItems;
                var repository = new EntityWorkItemRepository(() => context.Object);

                var activeWorkItem = repository.GetLastWorkItem(job.Object);

                Assert.True(activeWorkItem.IsActive());
            }