mercredi 29 juin 2016

Add items to collection in fake object

I have started my unit testing with Microsoft fakes , facing some difficulties while creating Shim objects. In my actual object I can easily add an item to my collection , not sure how to add fake object to a fake collection

Actual Implementation

var checklist2 = new CampusDoor.Fulfillment.Checklist.Messages.Entities.ApplicationChecklist();
                checklist2.ChecklistItems = new CampusDoor.Fulfillment.Checklist.Messages.Collections.ApplicationChecklistCollection();
                checklist2.ChecklistItems.Add(new ChecklistItem() { ChecklistItemCode = CampusDoor.Fulfillment.Checklist.Messages.Entities.Enumerators.ChecklistItemCode.BorrowerPermissionToPullCredit, IsChecked = true });
                checklist2.ChecklistItems.Add(new ChecklistItem() { ChecklistItemCode = CampusDoor.Fulfillment.Checklist.Messages.Entities.Enumerators.ChecklistItemCode.CosignerPermissionToPullCredit, IsChecked = true });      

Fake object creation so far

var checklist = new CampusDoor.Fulfillment.Checklist.Messages.Entities.Fakes.ShimApplicationChecklist()
                {
                    ChecklistItemsGet =()=> new CampusDoor.Fulfillment.Checklist.Messages.Collections.Fakes.ShimApplicationChecklistCollection()
                    {

                    },

                };

I need to pass IsChecked = true of ChecklistItem and add it to ApplicationChecklistCollection ,

Aucun commentaire:

Enregistrer un commentaire