コード例 #1
0
        public void GetBooksByUserShouldThowUnauthorizedSecurityException()
        {
            //  arrange
            NancyWebAppConfig.IdentityServerEnabled = true;
            var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup)));
            var client = new BasicClient(server.CreateClient(), "client", "secret");
            IEnumerable <Book> result = null;

            this.Invoking((a) =>
            {
                //  act
                result = client.GetBooksByUser("alfredorevilla").RunAsSynchronous();
            })

            //  assert
            .ShouldThrow <SecurityException>();
        }
コード例 #2
0
        public void GetBooksByUser_should_be_Ok()
        {
            //  arrange
            NancyWebAppConfig.IdentityServerEnabled = false;
            var server = new TestServer(new WebHostBuilder().UseStartup(typeof(Startup)));
            var client = new BasicClient(server.CreateClient(), "client", "secret");
            IEnumerable <Book> result = null;

            this.Invoking((a) =>
            {
                //  act
                result = client.GetBooksByUser("alfredorevilla").RunAsSynchronous();
            })

            //  assert
            .ShouldNotThrow();
            result.Should().NotBeNull();
            result.Count().Should().BeGreaterThan(0);
        }