public void Insert(StudentStatusDo studentStatus) { if (studentStatus == null) { throw new Exception("An insert with null value can't be made!"); } var query = InsertQuery.Create("studentStatuses", studentStatus); database.Execute(query); }
public void InsertQuery_SuccesfullyMappedExpected() { var tableName = "students"; StudentDo student = new StudentDo() { Id = 1, Age = "22", EmailAddress = "*****@*****.**", FirstName = "Iliusa", Gender = "M", LastName = "Niculae", LinkedStatus = "1" }; var expectedQuery = "insert into students (Id, Age, Gender, FirstName, LastName, EmailAddress, LinkedStatus) values ('1', '22', 'M', 'Iliusa', 'Niculae', '*****@*****.**', '1');"; var result = InsertQuery.Create(tableName, student); Assert.IsTrue(result.Equals(expectedQuery)); }
public void InsertQuery_WithTableNameNull_RaiseExceptionExpected() { var ex = Assert.Throws <Exception>(() => InsertQuery.Create(null, new StudentDo())); Assert.That(ex.Message, Is.EqualTo("Please make sure that table name or values used for creating the query aren't null!")); }