示例#1
0
        public void ClientsService_GetClientById_NonExistingId_ReturnsNull()
        {
            //Arrange
            string id     = ArrangeProvider._ID1_;
            Client client = ArrangeProvider.GetClient(id: id);

            var mockRepo = new Mock <IClientsRepository>();

            mockRepo.Setup(x => x.GetClientById(id)).Returns(client);

            var options = ArrangeProvider.GetAppSettingslOption();
            var mapper  = ArrangeProvider.GetMapper();

            var service = new ClientsService(options, mapper, mockRepo.Object);

            //Act
            var result = service.GetClientById(ArrangeProvider._ID0_);

            //Assert
            Assert.IsNull(result);
        }
示例#2
0
        public void ClientsService_GetClientByName_NonExistingName_ReturnsNull()
        {
            //Arrange
            string name   = ArrangeProvider._NAME_;
            Client client = ArrangeProvider.GetClient(email: name);

            var mockRepo = new Mock <IClientsRepository>();

            mockRepo.Setup(x => x.GetClientByName(name)).Returns(client);

            var options = ArrangeProvider.GetAppSettingslOption();
            var mapper  = ArrangeProvider.GetMapper();

            var service = new ClientsService(options, mapper, mockRepo.Object);

            //Act
            var result = service.GetClientByName(ArrangeProvider._NAME2_);

            //Assert
            Assert.IsNull(result);
        }
示例#3
0
        public void ClientsService_Authenticate_NonExistingEmail_ReturnsNull()
        {
            //Arrange
            string email  = ArrangeProvider._EMAIL_;
            Client client = ArrangeProvider.GetClient(id: email);

            var mockRepo = new Mock <IClientsRepository>();

            mockRepo.Setup(x => x.GetClientByEmail(email)).Returns(client);

            var options = ArrangeProvider.GetAppSettingslOption();
            var mapper  = ArrangeProvider.GetMapper();

            var service = new ClientsService(options, mapper, mockRepo.Object);

            //Act
            var result = service.Authenticate(ArrangeProvider._EMAIL2_);

            //Assert
            Assert.IsNull(result);
        }
示例#4
0
        public void ClientsService_Authenticate_ExistingEmailAndSpecificRole_ReturnsValidJWDTokenWithSameRole()
        {
            //Arrange
            string email  = ArrangeProvider._EMAIL_;
            string role   = Role.Admin;
            Client client = ArrangeProvider.GetClient(id: email, role: role);

            var mockRepo = new Mock <IClientsRepository>();

            mockRepo.Setup(x => x.GetClientByEmail(email)).Returns(client);

            var options = ArrangeProvider.GetAppSettingslOption();
            var mapper  = ArrangeProvider.GetMapper();

            var service = new ClientsService(options, mapper, mockRepo.Object);

            //Act
            var result = service.Authenticate(ArrangeProvider._EMAIL_);

            //Assert
            Assert.AreEqual(role, result.Role);
        }