예제 #1
0
        public void ShouldThrowArgumentNullExceptionWhenCommentIdIsDefaultInGet()
        {
            Guid testedId = default;

            Action testedAction = () => TestedService.Get(testedId);

            ShouldThrowArgumentNullExceptionWhenCommentIdIsDefaultInternal(testedAction);
        }
예제 #2
0
        public void ShouldThrowEntityNotFoundExceptionWhenEntityNotFoundByIdInGet()
        {
            Guid   testedId             = Guid.NewGuid();
            string expectedErrorMessage = $"Entity \"Comment\" - \"{testedId}\" not found.";

            Action testedAction = () => TestedService.Get(testedId);

            ShouldThrowEntityNotFoundExceptionWhenEntityNotFoundByIdInternal(testedAction, expectedErrorMessage);
        }
예제 #3
0
        public void ShouldExecuteQuery()
        {
            string expectedSqlQuery = $"SELECT * FROM [{TestedTableName}]";

            TestedService.Get();
            var lastQuery = LastQuery;

            Assert.NotNull(lastQuery);
            Assert.Equal(expectedSqlQuery, lastQuery.Value.Key);
            Assert.Null(lastQuery.Value.Value);
        }
예제 #4
0
        public void ShouldExecuteQuery()
        {
            Guid   testedId         = Guid.NewGuid();
            string expectedSqlQuery = $"SELECT * FROM [{TestedTableName}] WHERE Id = @P1";
            IEnumerable <KeyValuePair <string, object> > expectedArguments = new[] { new KeyValuePair <string, object>("P1", testedId) };

            TestedService.Get(testedId);
            var lastQuery = LastQuery;

            Assert.NotNull(lastQuery);
            Assert.Equal(expectedSqlQuery, lastQuery.Value.Key);
            Assert.NotNull(lastQuery.Value.Value);
            AssertArguments(expectedArguments, lastQuery.Value.Value);
        }
예제 #5
0
        public void ShouldReturnComment()
        {
            Guid testedId = Guid.NewGuid();
            ExtendedCommentModel expectedComment = new()
            {
                Id          = ReturnedTestedComment.Id,
                Message     = ReturnedTestedComment.Message,
                Description = ReturnedTestedComment.Description
            };

            ExtendedCommentModel result = TestedService.Get(testedId);

            Assert.NotNull(result);
            Assert.Equal(expectedComment.Id, result.Id);
            Assert.Equal(expectedComment.Description, result.Description);
            Assert.Equal(expectedComment.Message, result.Message);
        }
    }
예제 #6
0
        public void ShouldReturnMappedComments()
        {
            int          expectedCommentsCount = 1;
            CommentModel expectedCommentModel  = new()
            {
                Id = ReturnedTestedComment.Id,
                AppearanceCount = ReturnedTestedComment.AppearanceCount,
                Message         = ReturnedTestedComment.Message
            };

            IEnumerable <CommentModel> result = TestedService.Get();
            var firstItem = result.FirstOrDefault();

            Assert.NotNull(result);
            Assert.NotEmpty(result);
            Assert.Equal(expectedCommentsCount, result.Count());
            Assert.NotNull(firstItem);
            Assert.Equal(expectedCommentModel.Id, firstItem.Id);
            Assert.Equal(expectedCommentModel.AppearanceCount, firstItem.AppearanceCount);
            Assert.Equal(expectedCommentModel.Message, firstItem.Message);
        }
    }