public async Task DeleteCompanyAsync_ValidId_ShouldReturnDeletedCompany()
        {
            // Arrange
            var existingCompany = new GetCompanyPayload
            {
                Id = Guid.NewGuid().ToString(),
            };

            var expectedResponseContent =
                new StringContent(JsonConvert.SerializeObject(existingCompany, this.fixture.JsonSerializerSettings));

            var expectedResponse = new HttpResponseMessage
            {
                Content = expectedResponseContent,
            };

            var companyApi = this.fixture.GetCompanyApi(expectedResponse);

            var deleteCompanyResponse = new DeleteCompanyResponse();

            // Act
            Func <Task> act = async() => deleteCompanyResponse = await companyApi.DeleteCompanyAsync(existingCompany.Id);

            // Assert
            await act.Should().NotThrowAsync();

            deleteCompanyResponse.Id.Should().Be(existingCompany.Id);
        }
        public async Task SetPackageCompanyAsync_ValidRequest_ShouldReturnVoid()
        {
            // Arrange
            var existingProject = new GetProjectPayload
            {
                Id = Guid.NewGuid().ToString(),
            };

            var existingPackage = new GetPackagePayload
            {
                Id        = Guid.NewGuid().ToString(),
                ProjectId = existingProject.Id,
            };

            var existingCompany = new GetCompanyPayload
            {
                Id = Guid.NewGuid().ToString(),
            };

            var setCompanyAssociationRequest = new SetCompanyAssociationRequest(existingCompany.Id);

            var expectedResponseMessage = new HttpResponseMessage();

            var packageApi = this.fixture.GetPackageApi(expectedResponseMessage);

            // Act
            Func <Task> act = async() => await packageApi.SetPackageCompanyAsync(existingProject.Id, existingPackage.Id, setCompanyAssociationRequest);

            // Assert
            await act.Should().NotThrowAsync();
        }
        public async Task SetPackageCompanyAsync_InvalidProjectId_ShouldThrowArgumentNullException(string projectId)
        {
            // Arrange
            var existingProject = new GetProjectPayload
            {
                Id = Guid.NewGuid().ToString(),
            };

            var existingPackage = new GetPackagePayload
            {
                Id        = Guid.NewGuid().ToString(),
                ProjectId = existingProject.Id,
            };

            var existingCompany = new GetCompanyPayload
            {
                Id = Guid.NewGuid().ToString(),
            };

            var setCompanyAssociationRequest = new SetCompanyAssociationRequest(existingCompany.Id);

            var packageApi = this.fixture.GetPackageApi();

            // Act
            Func <Task> act = async() => await packageApi.SetPackageCompanyAsync(projectId, existingPackage.Id, setCompanyAssociationRequest);

            // Assert
            await act.Should().ThrowAsync <ArgumentNullException>();
        }
Example #4
0
        public async Task UpdateCompanyAsync_ValidRequest_ShouldReturnUpdatedCompany()
        {
            // Arrange
            var existingCompany = new GetCompanyPayload
            {
                Id   = Guid.NewGuid().ToString(),
                Name = "TestName",
            };

            var updateCompanyRequest = new UpdateCompanyRequest
            {
                Name = "NewName",
            };

            var expectedUpdatedCompany = new UpdateCompanyResponse
            {
                Id   = existingCompany.Id,
                Name = updateCompanyRequest.Name,
            };

            var expectedResponseContent = new StringContent(JsonConvert.SerializeObject(expectedUpdatedCompany, this.fixture.JsonSerializerSettings));

            var expectedResponse = new HttpResponseMessage
            {
                Content = expectedResponseContent,
            };

            var companyApi = this.fixture.GetCompanyApi(expectedResponse);

            var updateCompanyResponse = new UpdateCompanyResponse();

            // Act
            Func <Task> act = async() =>
                              updateCompanyResponse = await companyApi.UpdateCompanyAsync(existingCompany.Id, updateCompanyRequest);

            // Assert
            await act.Should().NotThrowAsync();

            using (new AssertionScope())
            {
                updateCompanyResponse.Id.Should().Be(existingCompany.Id);
                updateCompanyResponse.Name.Should().Be(expectedUpdatedCompany.Name);
            }
        }