Пример #1
0
        public async Task CanCrudStoriesAndFeatures()
        {
            var client = new LeanwareTestClient(_factory);

            var featureTitle = RandomFeatureTitle;
            var feature      = new
            {
                Id    = 0,
                Title = featureTitle,
                Tags  = RandomFeatureTags
            };

            feature = await client.PostSelf("api/features", feature);

            feature.Id.Should().BeGreaterThan(0);
            feature.Title.Should().Be(featureTitle);

            var featurePath = $"api/features/{feature.Id}";

            var updatedFeature = new
            {
                Title = $"{featureTitle} and {featureTitle}"
            };

            await client.Patch(featurePath, updatedFeature);

            feature = await client.Get(featurePath, feature);

            feature.Title.Should().Be($"{featureTitle} and {featureTitle}");

            var storyTitle = RandomStoryTitle;

            var story = new
            {
                Id          = 0,
                Title       = storyTitle,
                Description = nameof(CanCrudStoriesAndFeatures),
                Tags        = RandomStoryTags,
                FeatureId   = feature.Id
            };

            story = await client.PostSelf("api/stories", story);

            story.Id.Should().BeGreaterThan(0);

            var storyPath = $"api/stories/{story.Id}";

            story.Title.Should().Be(storyTitle);

            var updatedStory = new
            {
                Title = $"{storyTitle} and {storyTitle}"
            };

            await client.Patch(storyPath, updatedStory);

            story = await client.Get(storyPath, story);

            story.Title.Should().Be($"{storyTitle} and {storyTitle}");

            await client.Delete(storyPath);

            var deletedStory = await client.Get(storyPath);

            deletedStory.StatusCode.Should().Be(HttpStatusCode.NotFound);

            await client.Delete(featurePath);

            var deletedFeature = await client.Get(featurePath);

            deletedFeature.StatusCode.Should().Be(HttpStatusCode.NotFound);
        }