Exemplo n.º 1
0
        public void GetRatingsThrowsExceptionBecauseOfRatingIdIsUnspecified()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            RawDataContainer rawDataContainer =
                TestDataCreator.CreateRawDataContainerWithBasicInfo();

            Assert.Throws <InvalidOperationException>(
                () => appraiser.GetRatings(rawDataContainer, outputResults: false)
                );
            Assert.Throws <InvalidOperationException>(
                () => appraiser.GetRatings(rawDataContainer, outputResults: true)
                );
        }
Exemplo n.º 2
0
        public void GetRatingsThrowsExceptionBecauseOfNullContainer()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            Assert.Throws <ArgumentNullException>(
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
                () => appraiser.GetRatings(rawDataContainer: null, outputResults: false)
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
                );
            Assert.Throws <ArgumentNullException>(
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
                () => appraiser.GetRatings(rawDataContainer: null, outputResults: true)
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
                );
        }
Exemplo n.º 3
0
        public void CallGetRatingsWithConteinerWithRandomData(int itemsCount)
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            Guid ratingId = Guid.NewGuid();

            appraiser.RatingId = ratingId;

            IReadOnlyList <BasicInfo> items =
                TestDataCreator.CreateBasicInfoListRandomly(itemsCount);

            RawDataContainer rawDataContainer =
                TestDataCreator.CreateRawDataContainerWithBasicInfo(items);

            IReadOnlyList <ResultInfo> actualValue = appraiser.GetRatings(
                rawDataContainer, outputResults: false
                );

            IReadOnlyList <ResultInfo> expectedValue =
                TestDataCreator.CreateExpectedValueForBasicInfo(
                    ratingId, rawDataContainer, items
                    );

            Assert.NotNull(actualValue);
            Assert.NotEmpty(actualValue);
            Assert.All(expectedValue, resultInfo => actualValue.Contains(resultInfo));
        }
Exemplo n.º 4
0
        public void CallGetRatingsWithConteinerWithThreeItems()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            Guid ratingId = Guid.NewGuid();

            appraiser.RatingId = ratingId;

            var item1 = new BasicInfo(
                thingId: 1, title: "Title-1", voteCount: 11, voteAverage: 9.7
                );
            var item2 = new BasicInfo(
                thingId: 2, title: "Title-2", voteCount: 12, voteAverage: 9.8
                );
            var item3 = new BasicInfo(
                thingId: 3, title: "Title-3", voteCount: 13, voteAverage: 9.9
                );

            RawDataContainer rawDataContainer =
                TestDataCreator.CreateRawDataContainerWithBasicInfo(item1, item2, item3);

            IReadOnlyList <ResultInfo> actualValue = appraiser.GetRatings(
                rawDataContainer, outputResults: false
                );

            IReadOnlyList <ResultInfo> expectedValue =
                TestDataCreator.CreateExpectedValueForBasicInfo(
                    ratingId, rawDataContainer, item1, item2, item3
                    );

            Assert.NotNull(actualValue);
            Assert.NotEmpty(actualValue);
            Assert.All(expectedValue, resultInfo => actualValue.Contains(resultInfo));
        }
Exemplo n.º 5
0
        public void CallGetRatingsWithConteinerWithOneItem()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            Guid ratingId = Guid.NewGuid();

            appraiser.RatingId = ratingId;

            var item = new BasicInfo(
                thingId: 1, title: "Title", voteCount: 10, voteAverage: 9.9
                );

            RawDataContainer rawDataContainer =
                TestDataCreator.CreateRawDataContainerWithBasicInfo(item);

            IReadOnlyList <ResultInfo> actualValue = appraiser.GetRatings(
                rawDataContainer, outputResults: false
                );

            IReadOnlyList <ResultInfo> expectedValue =
                TestDataCreator.CreateExpectedValueForBasicInfo(
                    ratingId, rawDataContainer, item
                    );

            Assert.NotNull(actualValue);
            Assert.NotEmpty(actualValue);
            Assert.Single(actualValue);
            Assert.Equal(expectedValue.Single(), actualValue.Single());
        }
Exemplo n.º 6
0
        public void CallGetRatingsWithEmptyConteiner()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            Guid ratingId = Guid.NewGuid();

            appraiser.RatingId = ratingId;

            RawDataContainer rawDataContainer =
                TestDataCreator.CreateRawDataContainerWithBasicInfo();

            IReadOnlyList <ResultInfo> actualValue = appraiser.GetRatings(
                rawDataContainer, outputResults: false
                );

            IReadOnlyList <ResultInfo> expectedValue = new List <ResultInfo>();

            Assert.NotNull(actualValue);
            Assert.Empty(actualValue);
            Assert.Equal(expectedValue, actualValue);
        }