public void ConstructorShould_CreateCategoryInfoService() { // Arrange var EfRepositoryStub = new Mock <IEfRepository <ContactInfo> >(); var SaveContextStub = new Mock <ISaveContext>(); // Act var contactInfoService = new TelerikAcademy.FinalProject.Services.ContactInfoService(EfRepositoryStub.Object, SaveContextStub.Object); // Assert Assert.IsNotNull(contactInfoService); }
public void GetAll_Should_CallRepository_All() { // Arrange var EfRepositoryStub = new Mock <IEfRepository <ContactInfo> >(); var SaveContextStub = new Mock <ISaveContext>(); var contactInfoService = new TelerikAcademy.FinalProject.Services.ContactInfoService(EfRepositoryStub.Object, SaveContextStub.Object); // Act contactInfoService.GetAll(); // Assert EfRepositoryStub.Verify(x => x.All, Times.Once); }
public void Update_Should_CallContextCommit() { // Arrange var EfRepositoryStub = new Mock <IEfRepository <ContactInfo> >(); var SaveContextMock = new Mock <ISaveContext>(); var contactInfoService = new TelerikAcademy.FinalProject.Services.ContactInfoService(EfRepositoryStub.Object, SaveContextMock.Object); ContactInfo contact = new ContactInfo(); // Act contactInfoService.Update(contact); // Assert SaveContextMock.Verify(x => x.Commit(), Times.Once); }
public void GetById_ShouldReturnsNullWhenContactInfoIdIsNull() { //Arrange var EfRepositoryStub = new Mock <IEfRepository <ContactInfo> >(); var SaveContextStub = new Mock <ISaveContext>(); Guid?contactInfoId = Guid.NewGuid(); var contactInfoService = new TelerikAcademy.FinalProject.Services.ContactInfoService(EfRepositoryStub.Object, SaveContextStub.Object); // Act ContactInfo contactInfoModel = contactInfoService.GetById(null); // Assert Assert.IsNull(contactInfoModel); }