Exemple #1
0
        public void GetTotalCount_ParametersIsNull_ThrowsArgumentNullException()
        {
            //Arrange
            var repository = new EFRepositoryTester();

            repository.Initialize();

            //Act
            //Assert
            repository.GetTotalCount(null);
        }
Exemple #2
0
        public void GetTotalCount_NoEntities_ReturnsZero()
        {
            //Arrange
            var repository = new EFRepositoryTester();

            repository.Initialize();

            //Act
            var result = repository.GetTotalCount(new OperationParameters());

            //Assert
            Assert.AreEqual(0, result);
        }
Exemple #3
0
        public void GetTotalCount_EntitiesExist_ReturnsEntitiesCount()
        {
            //Arrange
            var repository = new EFRepositoryTester();

            repository.Initialize();

            var addingDate = DateTime.UtcNow;

            var manager1 = new Manager()
            {
                Director        = director,
                ManagerTrackers = new List <ManagerTracker>()
                {
                    new ManagerTracker()
                },
                Office   = office1,
                Computer = new Computer()
                {
                    Data = "data", Admin = admin
                },
                Things = new List <Thing>()
                {
                    new Thing()
                    {
                        Id    = 1,
                        Admin = admin,
                        Data  = "data"
                    },
                    new Thing()
                    {
                        Id    = 2,
                        Admin = admin,
                        Data  = "data"
                    }
                },
                Description = new Description()
                {
                    Data = "data"
                },
                Data     = "data",
                Car      = car1,
                Projects = new List <Project>()
                {
                    project1
                }
            };

            var manager2 = new Manager()
            {
                Director        = director,
                ManagerTrackers = new List <ManagerTracker>()
                {
                    new ManagerTracker()
                },
                Office   = office2,
                Computer = new Computer()
                {
                    Data = "data", Admin = admin
                },
                Things = new List <Thing>()
                {
                    new Thing()
                    {
                        Id    = 1,
                        Admin = admin,
                        Data  = "data"
                    },
                    new Thing()
                    {
                        Id    = 2,
                        Admin = admin,
                        Data  = "data"
                    }
                },
                Description = new Description()
                {
                    Data = "data"
                },
                Data     = "data",
                Car      = car2,
                Projects = new List <Project>()
                {
                    project2
                }
            };

            repository.Add(new AddOperationParameters <Manager>()
            {
                Entity            = manager1,
                OperationDateTime = addingDate
            });

            repository.Add(new AddOperationParameters <Manager>()
            {
                Entity            = manager2,
                OperationDateTime = addingDate
            });

            repository.Delete(new DeleteOperationParameters()
            {
                OperationDateTime = DateTime.UtcNow,
                PrimaryKeys       = new object[] { manager2.Id }
            });

            //Act
            var result = repository.GetTotalCount(new OperationParameters());

            //Assert
            Assert.AreEqual(1, result);
        }