public void AddСustomer(CustomerRegistrationInfo customerRegistrationInfo) { var сustomerEntity = new СustomerEntity { Login = customerRegistrationInfo.Login, Password = customerRegistrationInfo.Password }; if (сustomerRepository.Contains(сustomerEntity)) { throw new ArgumentException("This customer has been registered. Can't continue"); } this.сustomerRepository.Add(сustomerEntity); this.сustomerRepository.Save(); }
public void GetСustomerById_ShouldGetСustomerById() { // Arrange var Id = 12; var mock = new Mock <IСustomerRepository>(); var сustomerEntity = new СustomerEntity { Id = Id }; mock.Setup(a => a.GetById(It.IsAny <int>())).Returns(сustomerEntity); mock.Setup(a => a.ContainsId(It.IsAny <int>())).Returns(true); var сustomerService = new СustomerService(mock.Object); // Act var resylt = сustomerService.GetСustomerById(Id); // Assert mock.Verify(a => a.GetById(Id)); Assert.AreEqual(resylt, сustomerEntity); }
public void Remove(СustomerEntity сustomerEntity) { this.dbContext.Сustomers.Remove(сustomerEntity); }
public bool Contains(СustomerEntity сustomerEntity) { return(this.dbContext.Сustomers.Any(a => a.Login == сustomerEntity.Login && a.Password == сustomerEntity.Password)); }
public void Add(СustomerEntity сustomerEntity) { this.dbContext.Сustomers.Add(сustomerEntity); }