Esempio n. 1
0
 public void RemoveClaimAsync_InvalidModel_DoesNotCallIdentityAdmin()
 {
     Delete("api/Clients/ /claims/color/blue");
     Delete("api/Clients/123/claims/ /blue");
     Delete("api/Clients/123/claims/color/ ");
     ClientServiceImpl.VerifyRemoveClaimAsyncNotCalled();
 }
Esempio n. 2
0
 public void AddClaimAsync_CallsIdentityAdmin()
 {
     Post("api/Clients/123/claim", new ClientClaimValue {
         Type = "color", Value = "blue"
     });
     ClientServiceImpl.VerifyAddClaimAsync("123", "color", "blue");
 }
Esempio n. 3
0
        public void RemoveClaimAsync_IdentityAdminThrows_ReturnsErrors()
        {
            ClientServiceImpl.SetupRemoveClaimAsync(new Exception("Boom"));
            var resp = Delete("api/Clients/123/claim/123");

            Assert.AreEqual(HttpStatusCode.InternalServerError, resp.StatusCode);
        }
Esempio n. 4
0
        public void GetClientAsync_ClientNotFound_ReturnsNotFound()
        {
            ClientServiceImpl.SetupGetClientAsync((ClientDetail)null);
            var resp = Get("api/Clients/123");

            Assert.AreEqual(HttpStatusCode.NotFound, resp.StatusCode);
        }
Esempio n. 5
0
        public void GetClientsAsync_IdentityAdminThrows_ReturnsErrors()
        {
            ClientServiceImpl.SetupQueryClientsAsync(new Exception("Boom"));
            var response = Get("api/Clients");

            Assert.AreEqual(HttpStatusCode.InternalServerError, response.StatusCode);
        }
Esempio n. 6
0
        public void CreateClientAsync_InvalidModel_DoesNotCallIdentityAdmin()
        {
            var propertyValuesNoName = new List <PropertyValue>
            {
                new PropertyValue {
                    Type = "ClientName", Value = ""
                },
                new PropertyValue {
                    Type = "ClientId", Value = "testId"
                }
            };

            var propertyValuesNoId = new List <PropertyValue>
            {
                new PropertyValue {
                    Type = "ClientName", Value = "testName"
                },
                new PropertyValue {
                    Type = "ClientId", Value = ""
                }
            };

            Post("api/Clients", propertyValuesNoName);
            Post("api/Clients", propertyValuesNoId);
            Post("api/Clients", (IEnumerable <PropertyValue>)null);
            ClientServiceImpl.VerifyCreateClientAsyncNotCalled();
        }
Esempio n. 7
0
        public void AddClaimAsync_IdentityAdminThrows_ReturnsErrors()
        {
            ClientServiceImpl.SetupAddClaimAsync(new Exception("Boom"));
            var resp = Post("api/Clients/123/claim", new ClientClaimValue {
                Type = "color", Value = "blue"
            });

            Assert.AreEqual(HttpStatusCode.InternalServerError, resp.StatusCode);
        }
Esempio n. 8
0
        public void RemoveClaimAsync_IdentityAdminReturnsError_ReturnsError()
        {
            ClientServiceImpl.SetupRemoveClaimAsync("foo", "bar");
            var resp = Delete("api/Clients/123/claim/123");

            Assert.AreEqual(HttpStatusCode.BadRequest, resp.StatusCode);
            var error = resp.Content.ReadAsAsync <ErrorModel>().Result;

            Assert.AreEqual(2, error.Errors.Length);
            CollectionAssert.Contains(error.Errors, "foo");
            CollectionAssert.Contains(error.Errors, "bar");
        }
Esempio n. 9
0
        public void GetClientAsync_IdentityAdminReturnsErrors_ReturnsErrors()
        {
            ClientServiceImpl.SetupGetClientAsync("foo", "bar");
            var response = Get("api/Clients/123");

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            var error = response.Content.ReadAsAsync <ErrorModel>().Result;

            Assert.AreEqual(2, error.Errors.Length);
            CollectionAssert.Contains(error.Errors, "foo");
            CollectionAssert.Contains(error.Errors, "bar");
        }
Esempio n. 10
0
        public void AddClaimAsync_IdentityAdminReturnsError_ReturnsError()
        {
            ClientServiceImpl.SetupAddClaimAsync("foo", "bar");
            var resp = Post("api/Clients/123/claim", new ClientClaimValue {
                Type = "color", Value = "blue"
            });

            Assert.AreEqual(HttpStatusCode.BadRequest, resp.StatusCode);
            var error = resp.Content.ReadAsAsync <ErrorModel>().Result;

            Assert.AreEqual(2, error.Errors.Length);
            CollectionAssert.Contains(error.Errors, "foo");
            CollectionAssert.Contains(error.Errors, "bar");
        }
Esempio n. 11
0
 public void AddClaimAsync_InvalidModel_DoesNotCallIdentityAdmin()
 {
     Post("api/Clients/123/claim", new ClientClaimValue {
         Type = "", Value = "blue"
     });
     Post("api/Clients/123/claim", new ClientClaimValue {
         Type = "color", Value = ""
     });
     Post("api/Clients/ /claim", new ClientClaimValue {
         Type = "color", Value = "blue"
     });
     Post("api/Clients/123/claim", (ClientClaimValue)null);
     ClientServiceImpl.VerifyAddClaimAsyncNotCalled();
 }
Esempio n. 12
0
        public void CreateClientAsync_IdentityAdminThrows_ReturnsErrors()
        {
            ClientServiceImpl.SetupCreateClientAsync(new Exception("Boom"));
            var propertyValuesNoName = new List <PropertyValue>
            {
                new PropertyValue {
                    Type = "ClientName", Value = "testName"
                },
                new PropertyValue {
                    Type = "ClientId", Value = "testId"
                }
            };
            var response = Post("api/Clients", propertyValuesNoName);

            Assert.AreEqual(HttpStatusCode.InternalServerError, response.StatusCode);
        }
Esempio n. 13
0
        public void CreateClientAsync_ValidModel_CallsIdentityAdmin()
        {
            ClientServiceImpl.SetupCreateClientAsync(new CreateResult {
                Subject = "123"
            });
            var propertyValues = new List <PropertyValue>
            {
                new PropertyValue {
                    Type = "ClientName", Value = "testName"
                },
                new PropertyValue {
                    Type = "ClientId", Value = "testId"
                }
            };

            Post("api/Clients", propertyValues);
            ClientServiceImpl.VerifyCreateClientAsync();
        }
Esempio n. 14
0
        public void CreateClientAsync_IdentityAdminReturnsSuccess_CorrectResults()
        {
            ClientServiceImpl.SetupCreateClientAsync(new CreateResult {
                Subject = "123"
            });
            var propertyValues = new List <PropertyValue>
            {
                new PropertyValue {
                    Type = "ClientName", Value = "testName"
                },
                new PropertyValue {
                    Type = "ClientId", Value = "testId"
                }
            };
            var response = Post("api/Clients", propertyValues);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.AreEqual("/api/clients/123", response.Headers.Location.ToString());
        }
Esempio n. 15
0
        public void CreateClientAsync_IdentityAdminReturnsErrors_ReturnsErrors()
        {
            ClientServiceImpl.SetupCreateClientAsync("foo", "bar");
            var propertyValuesNoName = new List <PropertyValue>
            {
                new PropertyValue {
                    Type = "ClientName", Value = "testName"
                },
                new PropertyValue {
                    Type = "ClientId", Value = "testId"
                }
            };
            var response = Post("api/Clients", propertyValuesNoName);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            var error = response.Content.ReadAsAsync <ErrorModel>().Result;

            Assert.AreEqual(2, error.Errors.Length);
            CollectionAssert.Contains(error.Errors, "foo");
            CollectionAssert.Contains(error.Errors, "bar");
        }
Esempio n. 16
0
        public ClientServiceImplTest()
        {
            this.person = new Person(
                Option.None <string>(),
                PersonFirstName.Create("john").Value,
                PersonName.Create("smith").Value,
                PersonEmail.Create("*****@*****.**").Value);
            this.personQuery = Substitute.For <PersonQuery>();
            this.personQuery.Exist(this.person).Returns(true);

            var mediator = Substitute.For <IMediator>();

            this.personRepository = Substitute.For <PersonRepository>();

            this.accomodation      = AccomodationTest.GetAccomodation();
            this.accomodationQuery = Substitute.For <AccomodationQuery>();
            this.accomodationQuery.Exist(this.accomodation).Returns(true);
            this.personQuery.IsAccomodationSold(this.accomodation).Returns(false);

            this.clientService = new ClientServiceImpl(this.personRepository,
                                                       this.personQuery, this.accomodationQuery, mediator);
        }
 public void GetMetadata_CallsClientManager()
 {
     Get("api");
     ClientServiceImpl.GetMetadataAsync();
 }
Esempio n. 18
0
 public void DeleteClientAsync_CallsIdentityAdmin()
 {
     Delete("api/Clients/123");
     ClientServiceImpl.VerifyDeleteClientAsync("123");
 }
Esempio n. 19
0
 public void GetClientsAsync_NoParams_CallsIdentityAdmin()
 {
     Get("api/Clients");
     ClientServiceImpl.VerifyQueryClientsAsync();
 }
Esempio n. 20
0
 public void GetClientAsync_CallsIdentityAdmin()
 {
     Get("api/Clients/123");
     ClientServiceImpl.VerifyGetClientAsync("123");
 }
Esempio n. 21
0
 public void GetClientsAsync_WithParams_PassesParamsToIdentityAdmin()
 {
     Get("api/Clients?filter=foo&start=7&count=25");
     ClientServiceImpl.VerifyQueryClientsAsync("foo", 7, 25);
 }
Esempio n. 22
0
 //Pour les tests unitaires
 public static ClientController getClientController()
 {
     return(new ClientController(ClientServiceImpl.getClientServiceImpl()));
 }
Esempio n. 23
0
 public void RemoveClaimAsync_CallsIdentityAdmin()
 {
     Delete("api/Clients/123/claim/123");
     ClientServiceImpl.VerifyRemoveClaimAsync("123", "123");
 }