public void ToTransfertObject_ProvidingNull_ThrowException() { InstrumentEF instrument = null; LibUserEF libUser = null; CategoryEF category = null; SheetEF sheet = null; SheetPartEF sheetPart = null; //ACT Assert.ThrowsException <ArgumentNullException>(() => instrument.ToTransferObject()); Assert.ThrowsException <ArgumentNullException>(() => libUser.ToTransferObject()); Assert.ThrowsException <ArgumentNullException>(() => category.ToTransferObject()); Assert.ThrowsException <ArgumentNullException>(() => sheet.ToTransferObject()); Assert.ThrowsException <ArgumentNullException>(() => sheetPart.ToTransferObject()); }
public static SheetPartTO ToTransferObject(this SheetPartEF SheetPart) { if (SheetPart is null) { throw new ArgumentNullException(nameof(SheetPart)); } return(new SheetPartTO { Id = SheetPart.Id, Path = SheetPart.Path, Sheet = SheetPart.Sheet.ToTransferObject(), Instrument = SheetPart.Instrument.ToTransferObject(), Part = SheetPart.Part, }); }
public static SheetPartEF UpdateFromDetached(this SheetPartEF AttachedEF, SheetPartEF DetachedEF) { if (AttachedEF is null) { throw new ArgumentNullException(nameof(AttachedEF)); } if (DetachedEF is null) { throw new ArgumentNullException(nameof(DetachedEF)); } if ((AttachedEF != default) && (DetachedEF != default)) { AttachedEF.Id = DetachedEF.Id; AttachedEF.Sheet = DetachedEF.Sheet; AttachedEF.Instrument = DetachedEF.Instrument; AttachedEF.Path = DetachedEF.Path; AttachedEF.Part = DetachedEF.Part; } return(AttachedEF); }
public void ToTransfertObject_Successful() { //ARRANGE var instrument = new InstrumentEF { Id = 4, Name = "Saxophone", UserInstruments = new List <UserInstruEF> { new UserInstruEF { InstrumentId = 4, LibUserId = 1 } } }; var libUser = new LibUserEF { Id = 1, IdentityUserId = 24, UserInstruments = new List <UserInstruEF> { new UserInstruEF { InstrumentId = 4, LibUserId = 1 } } }; var category = new CategoryEF { Id = 2, Name = "Jazz" }; var sheet = new SheetEF { Id = 3, Name = "Sam's Dixie", Category = category, IsCurrent = true, IsIndependance = true, IsGarde = false, }; var sheetPart = new SheetPartEF { Id = 2, Instrument = instrument, Sheet = sheet, Path = "Path" }; //ACT var instrumentTO = instrument.ToTransferObject(); var libUserTO = libUser.ToTransferObject(); var categoryTO = category.ToTransferObject(); var sheetTO = sheet.ToTransferObject(); var sheetPartTO = sheetPart.ToTransferObject(); //Assert Assert.AreEqual(instrument.Name, instrumentTO.Name); Assert.AreEqual(libUser.IdentityUserId, libUserTO.IdentityUserId); Assert.AreEqual(category.Name, categoryTO.Name); Assert.AreEqual(sheet.Name, sheetTO.Name); Assert.AreEqual(sheetPart.Sheet.Name, sheetPartTO.Sheet.Name); }
public void UpdateFromDetached_ProvidingNullDetachedEF_ThrowException() { InstrumentEF instrumentDetached = null; LibUserEF libUserDetached = null; CategoryEF categoryDetached = null; SheetEF sheetDetached = null; SheetPartEF sheetPartDetached = null; var instrument = new InstrumentEF { Id = 4, Name = "Saxophone", UserInstruments = new List <UserInstruEF> { new UserInstruEF { InstrumentId = 4, LibUserId = 1 } } }; var libUser = new LibUserEF { Id = 1, IdentityUserId = 24, UserInstruments = new List <UserInstruEF> { new UserInstruEF { InstrumentId = 4, LibUserId = 1 } } }; var category = new CategoryEF { Id = 2, Name = "Jazz" }; var sheet = new SheetEF { Id = 3, Name = "Sam's Dixie", Category = category, IsCurrent = true, IsIndependance = true, IsGarde = false, }; var sheetPart = new SheetPartEF { Id = 2, Instrument = instrument, Sheet = sheet, Path = "Path" }; Assert.ThrowsException <ArgumentNullException>(() => instrument.UpdateFromDetached(instrumentDetached)); Assert.ThrowsException <ArgumentNullException>(() => libUser.UpdateFromDetached(libUserDetached)); Assert.ThrowsException <ArgumentNullException>(() => category.UpdateFromDetached(categoryDetached)); Assert.ThrowsException <ArgumentNullException>(() => sheet.UpdateFromDetached(sheetDetached)); Assert.ThrowsException <ArgumentNullException>(() => sheetPart.UpdateFromDetached(sheetPartDetached)); }