コード例 #1
0
        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();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void Remove(СustomerEntity сustomerEntity)
 {
     this.dbContext.Сustomers.Remove(сustomerEntity);
 }
コード例 #4
0
 public bool Contains(СustomerEntity сustomerEntity)
 {
     return(this.dbContext.Сustomers.Any(a =>
                                         a.Login == сustomerEntity.Login &&
                                         a.Password == сustomerEntity.Password));
 }
コード例 #5
0
 public void Add(СustomerEntity сustomerEntity)
 {
     this.dbContext.Сustomers.Add(сustomerEntity);
 }