Exemplo n.º 1
0
        public void MpaaRatingRepository_FetchNull_ReturnsAll()
        {
            // Arrange
            var repo = new MpaaRatingRepository();

            var list = repo.Fetch();

            Assert.IsNotNull(list);
            Assert.IsTrue(list.Any());
        }
        public void MpaaRatingRepository_FetchNull_ReturnsAll()
        {
            // Arrange
            var repo = new MpaaRatingRepository();

            var list = repo.Fetch();

            Assert.IsNotNull(list);
            Assert.IsTrue(list.Any());
        }
Exemplo n.º 3
0
        public void Initialize()
        {
            _showRepo       = new ShowRepository();
            _ratingRepo     = new MpaaRatingRepository();
            _creditTypeRepo = new CreditTypeRepository();
            _personRepo     = new PersonRepository();

            _ratings     = _ratingRepo.Fetch().ToList();
            _creditTypes = _creditTypeRepo.Fetch().ToList();
            _shows       = _showRepo.Fetch().ToList();
        }
Exemplo n.º 4
0
        public void Initialize()
        {
            _showRepo = new ShowRepository();
            _ratingRepo = new MpaaRatingRepository();
            _creditTypeRepo = new CreditTypeRepository();
            _personRepo = new PersonRepository();

            _ratings = _ratingRepo.Fetch().ToList();
            _creditTypes = _creditTypeRepo.Fetch().ToList();
            _shows = _showRepo.Fetch().ToList();
        }
Exemplo n.º 5
0
 public ShowViewModel()
 {
     var ratingsRepo = new MpaaRatingRepository();
     MpaaRatings = ratingsRepo.Fetch()
         .OrderBy(o => o.DisplayOrder)
             .ThenBy(o => o.Code)
             .Select(o => new SelectListItem
             {
                 Value = o.MpaaRatingId.ToString(),
                 Text = o.Code
             }).ToList();
 }
Exemplo n.º 6
0
        public void MpaaRatingRepository_InsertUpdateDelete_Works()
        {
            // Arrange
            var repo = new MpaaRatingRepository();
            var testItem = new MpaaRating
            {
                Name = "TestItem",
                Code = "TestItemCode",
                Description = "Blah",
                IsInactive = true,
                DisplayOrder = 99
            };

            // Act - Insert
            var insertedItem = repo.Persist(testItem);
            var newId = insertedItem.MpaaRatingId;

            // Assert for Insert
            Assert.IsTrue(newId > 0);
            var existingItem = repo.Fetch(newId).Single();
            Assert.IsTrue(existingItem.Name == "TestItem");
            Assert.IsTrue(existingItem.Code == "TestItemCode");
            Assert.IsTrue(existingItem.Description == "Blah");
            Assert.IsTrue(existingItem.IsInactive == true);
            Assert.IsTrue(existingItem.DisplayOrder == 99);

            // Act - Update
            existingItem.Name = "TestItem1";
            existingItem.Code = "TestItemCode1";
            existingItem.Description = "BlahBlah";
            existingItem.IsInactive = false;
            existingItem.DisplayOrder = 10;

            repo.Persist(existingItem);

            // Assert for Update
            var updatedItem = repo.Fetch(newId).Single();
            Assert.IsTrue(updatedItem.Name == "TestItem1");
            Assert.IsTrue(updatedItem.Code == "TestItemCode1");
            Assert.IsTrue(updatedItem.Description == "BlahBlah");
            Assert.IsTrue(updatedItem.IsInactive == false);
            Assert.IsTrue(updatedItem.DisplayOrder == 10);

            // Act - Delete
            updatedItem.IsMarkedForDeletion = true;
            var deletedItem = repo.Persist(updatedItem);

            // Assert for Delete
            Assert.IsNull(deletedItem);
            var emptyResult = repo.Fetch(newId);
            Assert.IsFalse(emptyResult.Any());
        }
Exemplo n.º 7
0
        public void MpaaRatingRepository_FetchAll_ReturnsData()
        {
            // Arrange
            var repo = new MpaaRatingRepository();

            // Act
            var results = repo.Fetch();

            // Assert
            Assert.IsTrue(results != null);
            Assert.IsTrue(results.Any());
            Assert.IsTrue(results.Count() == 6);
            Assert.IsTrue(results.ToList()[5].Name == "Unrated");
        }
        public void MpaaRatingRepository_InsertUpdateDelete()
        {
            // Arrange
            var repo    = new MpaaRatingRepository();
            var newItem = new MpaaRating
            {
                Code         = "TestCode",
                Name         = "TestName",
                IsInactive   = false,
                DisplayOrder = 99,
                Description  = "TestDescription"
            };
            var item  = repo.Persist(newItem);
            var newId = item.Id;

            // Act for Update
            item.Name         = "XYZ";
            item.Code         = "ABC";
            item.Description  = "PQR";
            item.IsInactive   = true;
            item.DisplayOrder = 999;
            item.IsDirty      = true;
            var updatedItem = repo.Persist(item);

            Assert.IsTrue(updatedItem.IsDirty == false);
            Assert.IsTrue(updatedItem.Name == "XYZ");
            Assert.IsTrue(updatedItem.Code == "ABC");
            Assert.IsTrue(updatedItem.Description == "PQR");
            Assert.IsTrue(updatedItem.IsInactive);
            Assert.IsTrue(updatedItem.DisplayOrder == 999);

            // Assert for Update
            var refetch = repo.Fetch(newId).First();

            Assert.IsTrue(refetch.Name == "XYZ");
            Assert.IsTrue(refetch.Code == "ABC");
            Assert.IsTrue(refetch.Description == "PQR");
            Assert.IsTrue(refetch.IsInactive);
            Assert.IsTrue(refetch.DisplayOrder == 999);

            // Clean-up (Act for Delete)
            item.IsMarkedForDeletion = true;
            repo.Persist(item);

            // Assert for Delete
            var result = repo.Fetch(newId);

            Assert.IsFalse(result.Any());
        }
Exemplo n.º 9
0
        public void MpaaRatingRepository_Delete_Deletes()
        {
            // Arrange
            var repo = new MpaaRatingRepository();
            var existingItem = repo.Fetch(3).Single();

            // Act
            existingItem.IsMarkedForDeletion = true;
            var deletedItem = repo.Persist(existingItem);

            // Assert for Delete
            Assert.IsNull(deletedItem);
            var emptyResult = repo.Fetch(3);
            Assert.IsFalse(emptyResult.Any());
        }
Exemplo n.º 10
0
        public void MpaaRatingRepository_FetchOne_ReturnsOne()
        {
            // Arrange
            var repo = new MpaaRatingRepository();
            var all = repo.Fetch(null).ToList();
            var mpaaRatingId = all[0].MpaaRatingId;
            var name = all[0].Name;
            var description = all[0].Description;

            var item = repo.Fetch(mpaaRatingId).Single();

            Assert.IsNotNull(item);
            Assert.IsTrue(item.MpaaRatingId == mpaaRatingId);
            Assert.IsTrue(item.Name == name);
            Assert.IsTrue(item.Description == description);
            Assert.IsFalse(item.IsMarkedForDeletion);
            Assert.IsFalse(item.IsDirty);
        }
Exemplo n.º 11
0
        public void MpaaRatingRepository_FetchOne_ReturnsData()
        {
            // Arrange
            var repo = new MpaaRatingRepository();

            // Act
            var results = repo.Fetch(3);

            // Assert
            Assert.IsTrue(results != null);
            Assert.IsTrue(results.Any());
            Assert.IsTrue(results.Count() == 1);
            var item = results.Single();
            Assert.IsTrue(item.MpaaRatingId == 3);
            Assert.IsFalse(item.IsMarkedForDeletion);
            Assert.IsFalse(item.IsDirty);
            Assert.IsFalse(item.IsGraphDirty);
        }
        public void MpaaRatingRepository_FetchOne_ReturnsOne()
        {
            // Arrange
            var repo         = new MpaaRatingRepository();
            var all          = repo.Fetch(null).ToList();
            var mpaaRatingId = all[0].Id;
            var name         = all[0].Name;
            var description  = all[0].Description;

            var item = repo.Fetch(mpaaRatingId).Single();

            Assert.IsNotNull(item);
            Assert.IsTrue(item.Id == mpaaRatingId);
            Assert.IsTrue(item.Name == name);
            Assert.IsTrue(item.Description == description);
            Assert.IsFalse(item.IsMarkedForDeletion);
            Assert.IsFalse(item.IsDirty);
        }
        public void MpaaRatingRepository_InsertDelete()
        {
            // Arrange
            var repo    = new MpaaRatingRepository();
            var newItem = new MpaaRating
            {
                Code         = "TestCode",
                Name         = "TestName",
                IsInactive   = false,
                DisplayOrder = 99,
                Description  = "TestDescription"
            };

            // Act for Insert
            var item  = repo.Persist(newItem);
            var newId = item.Id;

            // Assert for Insert - Make sure local object is updated
            Assert.IsTrue(item.Id > 0);
            Assert.IsFalse(item.IsMarkedForDeletion);
            Assert.IsFalse(item.IsDirty);

            // Assert for Insert - Make sure refetched object is correct
            var refetch = repo.Fetch(newId).First();

            Assert.IsTrue(refetch.Id == newId);
            Assert.IsFalse(refetch.IsMarkedForDeletion);
            Assert.IsFalse(refetch.IsDirty);
            Assert.IsTrue(refetch.Code == "TestCode");
            Assert.IsTrue(refetch.Name == "TestName");
            Assert.IsTrue(refetch.Description == "TestDescription");
            Assert.IsTrue(refetch.IsInactive == false);
            Assert.IsTrue(refetch.DisplayOrder == 99);

            // Clean-up (Act for Delete)
            item.IsMarkedForDeletion = true;
            repo.Persist(item);

            // Assert for Delete
            var result = repo.Fetch(newId);

            Assert.IsFalse(result.Any());
        }
Exemplo n.º 14
0
        public void MpaaRatingRepository_InsertDelete()
        {
            // Arrange
            var repo = new MpaaRatingRepository();
            var newItem = new MpaaRating
            {
                Code = "TestCode",
                Name = "TestName",
                IsInactive = false,
                DisplayOrder = 99,
                Description = "TestDescription"
            };

            // Act for Insert
            var item = repo.Persist(newItem);
            var newId = item.MpaaRatingId;

            // Assert for Insert - Make sure local object is updated
            Assert.IsTrue(item.MpaaRatingId > 0);
            Assert.IsFalse(item.IsMarkedForDeletion);
            Assert.IsFalse(item.IsDirty);

            // Assert for Insert - Make sure refetched object is correct
            var refetch = repo.Fetch(newId).First();
            Assert.IsTrue(refetch.MpaaRatingId == newId);
            Assert.IsFalse(refetch.IsMarkedForDeletion);
            Assert.IsFalse(refetch.IsDirty);
            Assert.IsTrue(refetch.Code == "TestCode");
            Assert.IsTrue(refetch.Name == "TestName");
            Assert.IsTrue(refetch.Description == "TestDescription");
            Assert.IsTrue(refetch.IsInactive == false);
            Assert.IsTrue(refetch.DisplayOrder == 99);

            // Clean-up (Act for Delete)
            item.IsMarkedForDeletion = true;
            repo.Persist(item);

            // Assert for Delete
            var result = repo.Fetch(newId);
            Assert.IsFalse(result.Any());
        }
Exemplo n.º 15
0
        public void MpaaRatingRepository_Insert_Insertss()
        {
            // Arrange
            var repo = new MpaaRatingRepository();
            var testItem = new MpaaRating
            {
                Name = "TestItem",
                Code = "TestItemCode",
                Description = "Blah",
                IsInactive = true,
                DisplayOrder = 99
            };

            // Act
            var insertedItem = repo.Persist(testItem);
            var newId = insertedItem.MpaaRatingId;

            // Assert
            Assert.IsTrue(newId > 0);
            var existingItem = repo.Fetch(newId).Single();
            Assert.IsTrue(existingItem.Name == "TestItem");
            Assert.IsTrue(existingItem.Code == "TestItemCode");
            Assert.IsTrue(existingItem.Description == "Blah");
            Assert.IsTrue(existingItem.IsInactive == true);
            Assert.IsTrue(existingItem.DisplayOrder == 99);
            Assert.IsFalse(existingItem.IsDirty);
            Assert.IsFalse(existingItem.IsMarkedForDeletion);
        }
Exemplo n.º 16
0
        public void MpaaRatingRepository_InsertUpdateDelete()
        {
            // Arrange
            var repo = new MpaaRatingRepository();
            var newItem = new MpaaRating
            {
                Code = "TestCode",
                Name = "TestName",
                IsInactive = false,
                DisplayOrder = 99,
                Description = "TestDescription"
            };
            var item = repo.Persist(newItem);
            var newId = item.MpaaRatingId;

            // Act for Update
            item.Name = "XYZ";
            item.Code = "ABC";
            item.Description = "PQR";
            item.IsInactive = true;
            item.DisplayOrder = 999;
            item.IsDirty = true;
            var updatedItem = repo.Persist(item);

            Assert.IsTrue(updatedItem.IsDirty == false);
            Assert.IsTrue(updatedItem.Name == "XYZ");
            Assert.IsTrue(updatedItem.Code == "ABC");
            Assert.IsTrue(updatedItem.Description == "PQR");
            Assert.IsTrue(updatedItem.IsInactive);
            Assert.IsTrue(updatedItem.DisplayOrder == 999);

            // Assert for Update
            var refetch = repo.Fetch(newId).First();
            Assert.IsTrue(refetch.Name == "XYZ");
            Assert.IsTrue(refetch.Code == "ABC");
            Assert.IsTrue(refetch.Description == "PQR");
            Assert.IsTrue(refetch.IsInactive);
            Assert.IsTrue(refetch.DisplayOrder == 999);

            // Clean-up (Act for Delete)
            item.IsMarkedForDeletion = true;
            repo.Persist(item);

            // Assert for Delete
            var result = repo.Fetch(newId);
            Assert.IsFalse(result.Any());
        }
Exemplo n.º 17
0
        public void MpaaRatingRepository_Update_Updates()
        {
            // Arrange
            var repo = new MpaaRatingRepository();
            var existingItem = repo.Fetch(2).Single();

            // Act - Update
            existingItem.Name = "TestItem1";
            existingItem.Code = "TestItemCode1";
            existingItem.Description = "Blah";
            existingItem.IsInactive = false;
            existingItem.DisplayOrder = 10;

            Assert.IsTrue(existingItem.IsDirty);
            Assert.IsTrue(existingItem.IsGraphDirty);

            repo.Persist(existingItem);

            // Assert for Update
            var updatedItem = repo.Fetch(2).Single();
            Assert.IsTrue(updatedItem.Name == "TestItem1");
            Assert.IsTrue(updatedItem.Code == "TestItemCode1");
            Assert.IsTrue(updatedItem.Description == "Blah");
            Assert.IsTrue(updatedItem.IsInactive == false);
            Assert.IsTrue(updatedItem.DisplayOrder == 10);
            Assert.IsFalse(existingItem.IsDirty);
            Assert.IsFalse(existingItem.IsGraphDirty);
        }