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());
        }
        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());
        }
        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());
        }
        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);
        }
Esempio n. 5
0
 private void New(object sender, ExecutedRoutedEventArgs e)
 {
     var newItem = new MpaaRating();
     _mpaaRatings.Add(newItem);
     ResultsListBox.SelectedItem = newItem;
 }