Exemplo n.º 1
0
        public async Task DeleteCompanyTagAsync_ExistingCompanyTagWithAssociation_ShouldDeleteCompanyTag()
        {
            // Arrange
            await this.fixture.ClearFactroInstanceAsync();

            var companyApi = this.fixture.GetService <ICompanyApi>();

            var existingCompany = await this.fixture.CreateTestCompanyAsync(companyApi);

            var existingCompanyTag = await this.fixture.CreateTestCompanyTagAsync(companyApi);

            var addCompanyTagRequest = new AddCompanyTagAssociationRequest(existingCompanyTag.Id);
            await companyApi.AddTagToCompanyAsync(existingCompany.Id, addCompanyTagRequest);

            var deleteCompanyTagResponse = new DeleteCompanyTagResponse();

            // Act
            Func <Task> act = async() => deleteCompanyTagResponse = await companyApi.DeleteCompanyTagAsync(existingCompanyTag.Id);

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

            using (new AssertionScope())
            {
                deleteCompanyTagResponse.Should().BeEquivalentTo(existingCompanyTag);

                (await this.fixture.GetCompanyTagsAsync(companyApi)).Should().NotContain(x => x.Id == existingCompanyTag.Id);
            }

            await this.fixture.ClearFactroInstanceAsync();
        }
Exemplo n.º 2
0
        public async Task DeleteCompanyTagAsync_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 deleteCompanyTagResponse = new DeleteCompanyTagResponse();

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

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

            deleteCompanyTagResponse.Id.Should().Be(existingCompany.Id);
        }