Exemplo n.º 1
0
        public async Task PostPackage_Add_data()
        {
            //Arrange
            var packagelist = new List <PackageIngestModel>()
            {
                new PackageIngestModel()
                {
                    Id = 1, package = "gatik", description = "It is a test ", url = "https://software.broadinstitute.org/gatk/", versions = new List <VersionIngestModel>()
                }
            };

            var package = new Package {
                Id = 1, ShortName = "gatik", Description = "It is a test ", Url = "https://software.broadinstitute.org/gatk/"
            };

            _packageRepositoryMock.Setup(x => x.CreateAsync(It.IsAny <Package>())).Returns(Task.CompletedTask);
            _packageRepositoryMock.Setup(x => x.packageExists(package));

            //Act
            var controller = new PackagesController(_packageRepositoryMock.Object);
            var result     = await controller.PostPackage(packagelist);

            //Assert
            Assert.NotNull(result);
            _packageRepositoryMock.Verify(m => m.CreateAsync(It.IsAny <Package>()), Times.Once);
        }
Exemplo n.º 2
0
        public async Task PostPackages_Return_BadRequest()
        {
            // Arrange
            List <PackageIngestModel> package = null;

            // Act
            // Assert
            try
            {
                var controller = new PackagesController(_packageRepositoryMock.Object);
                var result     = await controller.PostPackage(package);
            }
            catch (HttpResponseException ex)
            {
                Assert.Equal(HttpStatusCode.BadRequest, ex.Response.StatusCode);
                throw;
            }
        }