public async Task When_Invalid_Information_Inserted_Return_Error() { //Arrange var options = new DbContextOptionsBuilder <ContactsContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; contactsContext = new ContactsContext(options); dataLayer = new ContactsDataLayer(contactsContext); var contacts = new ContactsDTO() { ContactId = 1, FirstName = "Shamina", LastName = "Maharaj", Telephone = "032abcs", Mobile = "12345po", Email = "maharajshamina1gmailcom", DateCreated = DateTime.Now, DateUpdated = DateTime.Now, }; //Act BaseResponse <ContactsDTO> result = await dataLayer.AddNewContact(contacts); //Assert Assert.AreEqual(result.Result, null); Assert.AreEqual(result.ErrorStatus, ErrorStatus.Error); }
public void Setup() { var options = new DbContextOptionsBuilder <ContactsContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; contactsContext = new ContactsContext(options); dataLayer = new ContactsDataLayer(contactsContext); }
public async Task Information_Needs_To_Be_Correctly_InsertedAsync() { //Arrange var options = new DbContextOptionsBuilder <ContactsContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; contactsContext = new ContactsContext(options); dataLayer = new ContactsDataLayer(contactsContext); var contacts = new ContactsDTO() { ContactId = 1, FirstName = "Shamina", LastName = "Maharaj", Telephone = "0325516332", Mobile = "0829519581", Email = "*****@*****.**", DateCreated = DateTime.Now, DateUpdated = DateTime.Now, }; //Act BaseResponse <ContactsDTO> result = await dataLayer.AddNewContact(contacts); //Assert Assert.NotNull(result.Result); Assert.AreEqual(result.ErrorStatus, ErrorStatus.Success); Assert.AreEqual(result.Result.ContactId, contacts.ContactId); Assert.AreEqual(result.Result.FirstName, contacts.FirstName); Assert.AreEqual(result.Result.LastName, contacts.LastName); Assert.AreEqual(result.Result.Telephone, contacts.Telephone); Assert.AreEqual(result.Result.Mobile, contacts.Mobile); Assert.AreEqual(result.Result.Email, contacts.Email); Assert.AreEqual(result.Result.DateCreated, contacts.DateCreated); Assert.AreEqual(result.Result.DateUpdated, contacts.DateUpdated); }
public void Setup() { var options = new DbContextOptionsBuilder <ContactsContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; contactsContext = new ContactsContext(options); dataLayer = new ContactsDataLayer(contactsContext); contacts = new ContactsDTO() { ContactId = correctId, FirstName = "Shamina", LastName = "Maharaj", Telephone = "0325516332", Mobile = "0829519581", Email = "*****@*****.**", DateCreated = DateTime.Now.AddDays(-1), DateUpdated = DateTime.Now }; contactsContext.Contacts.Add(contacts); contactsContext.SaveChanges(); }
public ContactsController(IContactsDataLayer _dataLayer) { this.dataLayer = _dataLayer; }