Beispiel #1
0
        public async Task Get_package_with_null_return_object()
        {
            var fixture = new ParameterFixture();
            var result  = await StrikesRepository.GetPackage(fixture.Request, null, fixture.Logger);

            Assert.Equal("NotFoundObjectResult", result.GetTypeName());
        }
        public async Task Search_name_normal_case()
        {
            var fixture = new ParameterFixture();
            var service = new SearchService(fixture.SearchRepoitory);
            var results = await service.SearchNameAsync("h*");

            Assert.Equal(fixture.Expected, results);
            fixture.VerifyCreated();
        }
Beispiel #3
0
        public async Task Create_package_invalid()
        {
            var fixture = new ParameterFixture();

            fixture.SetUpCreated(fixture.CreatePackageFail);
            var result = await StrikesRepository.CreatePackage(fixture.Request, fixture.Collector, fixture.Logger);

            Assert.Equal("BadRequestObjectResult", result.GetTypeName());

            var expected = "[{\"MemberNames\":[\"Name\"],\"ErrorMessage\":\"The Name field is required.\"},{\"MemberNames\":[\"ProjectPage\"],\"ErrorMessage\":\"The ProjectPage field is not a valid fully-qualified http, https, or ftp URL.\"}]";

            Assert.Equal(expected, ((BadRequestObjectResult)result).Value);
        }
Beispiel #4
0
        public async Task Get_package_with_a_parameter()
        {
            var fixture  = new ParameterFixture();
            var document = new Package()
            {
                Name = "ushio",
            };

            var result = await StrikesRepository.GetPackage(fixture.Request, document, fixture.Logger);

            Assert.Equal("OkObjectResult", result.GetTypeName());
            Assert.Equal("ushio", result.GetPackageName());
        }
Beispiel #5
0
        public async Task Get_Packages_normal_case()
        {
            var fixture = new ParameterFixture();

            fixture.SetUpGetPackages();
            var result = await StrikesRepository.GetPackages(fixture.Request, fixture.SearchService, fixture.Logger);

            fixture.VerifyGetPackages();
            var Actual = result.GetPackages().ToArray()[0];

            Assert.Equal(fixture.ExpectedGetPackagesName, Actual.Name);
            Assert.Equal(fixture.ExpectedVersion, Actual.Releases[0].Version);
        }
Beispiel #6
0
        public async Task Create_package_success()
        {
            var fixture = new ParameterFixture();

            fixture.SetUpCreated(fixture.CreatePackageSuccess);

            var result = await StrikesRepository.CreatePackage(fixture.Request, fixture.Collector, fixture.Logger);

            Assert.Equal("CreatedResult", result.GetTypeName());

            fixture.VerifyCreated();
            var createdResult = (CreatedResult)result;

            Assert.Equal($"package/{fixture.Expected.Id}", (string)createdResult.Location);
            Assert.Equal(fixture.Expected.Id, ((Package)createdResult.Value).Id);
            fixture.Cleanup(); // Only in case you use Stream.
        }