コード例 #1
0
        public ActionResult ApproveBuyer(int id)
        {
            int approvalId = buyerRepo.Get(id).ApprovalId;

            buyerApprovalRepo.UpdateApproval(approvalId, true);

            return(RedirectToAction("BuyerList"));
        }
コード例 #2
0
        public async Task BoundaryTestfor_ValidUserEmailAsync()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            ////Action
            //  var getregisteredUser = await _userServices.GetUser(user.UserName);
            bool CheckEmail = Regex.IsMatch(result.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
            bool isEmail    = Regex.IsMatch(_buyer.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

            //Assert
            Assert.True(isEmail);
            Assert.True(CheckEmail);
        }
コード例 #3
0
        public async Task BoundaryTestFor_validUserNameLengthAsync()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            var MinLength = 3;
            var MaxLength = 50;

            //Action
            var actualLength = _buyer.FirstName.Length;

            //Assert
            Assert.InRange(result.FirstName.Length, MinLength, MaxLength);
            Assert.InRange(actualLength, MinLength, MaxLength);
        }
コード例 #4
0
        public async Task BoundaryTestfor_ValidId()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            Assert.InRange(_buyer.BuyerId.Length, 20, 30);
        }
コード例 #5
0
        public async void TestFor_CreateNewUser()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            //Assert
            Assert.Equal(_buyer.FirstName, result.FirstName);
        }
コード例 #6
0
        public async Task BoundaryTestfor_ValidUserNameAsync()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            bool getisUserName = Regex.IsMatch(result.FirstName, @"^[a-zA-Z0-9]{4,10}$", RegexOptions.IgnoreCase);
            bool isUserName    = Regex.IsMatch(_buyer.FirstName, @"^[a-zA-Z0-9]{4,10}$", RegexOptions.IgnoreCase);

            //Assert
            Assert.True(isUserName);
            Assert.True(getisUserName);
        }
コード例 #7
0
        public async Task TestFor_GetBuyerById()
        {
            //Arrange

            //mocking
            _mockCollection.Setup(op => op.FindSync(It.IsAny <FilterDefinition <Buyer> >(),
                                                    It.IsAny <FindOptions <Buyer, Buyer> >(),
                                                    It.IsAny <CancellationToken>()));

            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name));

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            //Assert
            Assert.NotNull(result);
        }
コード例 #8
0
        public ActionResult ViewProfile(int id)
        {
            Buyer buyer = buyerRepo.Get(id);

            return(View(buyer));
        }