示例#1
0
        public async Task Post_SystemRelation_Returns_201(bool withContract, bool withInterface, bool withFrequency)
        {
            //Arrange
            var input = await PrepareFullRelationAsync(withContract, withInterface, withFrequency);

            //Act
            using (var response = await SystemRelationHelper.SendPostRelationRequestAsync(input))
            {
                //Assert
                Assert.Equal(HttpStatusCode.Created, response.StatusCode);
                var relationsFrom = (await SystemRelationHelper.GetRelationsFromAsync(input.FromUsageId)).ToList();
                var relationsTo   = (await SystemRelationHelper.GetRelationsToAsync(input.ToUsageId)).ToList();
                var fromDto       = Assert.Single(relationsFrom);
                var toDto         = Assert.Single(relationsTo);

                fromDto.ToExpectedObject().ShouldMatch(toDto); //Same relation should yield same data at the dto level

                Assert.Equal(input.FromUsageId, fromDto.FromUsage.Id);
                Assert.Equal(input.ToUsageId, fromDto.ToUsage.Id);
                Assert.Equal(input.Description, fromDto.Description);
                Assert.Equal(input.Reference, fromDto.Reference);
                Assert.Equal(input.ContractId, fromDto.Contract?.Id);
                Assert.Equal(input.InterfaceId, fromDto.Interface?.Id);
                Assert.Equal(input.FrequencyTypeId, fromDto.FrequencyType?.Id);
            }
        }