コード例 #1
0
ファイル: ExtensionsTests.cs プロジェクト: Orl4ne/MusicAgora
        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());
        }
コード例 #2
0
ファイル: ExtensionsTests.cs プロジェクト: Orl4ne/MusicAgora
        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);
        }