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.º 2
0
 private void OnDelete()
 {
     if (SelectedItem != null)
     {
         SelectedItem.IsMarkedForDeletion = true;
         try
         {
             _repo.Persist(SelectedItem);
             Items.Remove(SelectedItem);
             SelectedItem = null;
         }
         catch
         {
             return;
         }
     }
 }
        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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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);
        }
Exemplo n.º 9
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);
        }