Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
0
        public void CheckRatingIdPropertyDefaultValue()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            Guid actualValue = appraiser.RatingId;

            Guid expectedValue = Guid.Empty;

            Assert.Equal(expectedValue, actualValue);
        }
Ejemplo n.º 5
0
        public void CheckTypeIdPropertyDefaultValue()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            Type actualValue = appraiser.TypeId;

            Type expectedValue = typeof(BasicInfo);

            Assert.NotNull(actualValue);
            Assert.Equal(expectedValue, actualValue);
        }
Ejemplo n.º 6
0
        public void SetRatingIdPropertyAndCompare()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            Guid expectedValue = Guid.NewGuid();

            appraiser.RatingId = expectedValue;

            Guid actualValue = appraiser.RatingId;

            Assert.Equal(expectedValue, actualValue);
        }
Ejemplo n.º 7
0
        public void CheckRatingNamePropertyDefaultValue()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            string actualValue = appraiser.RatingName;

            const string expectedValue = "Common rating";

            Assert.NotNull(actualValue);
            Assert.NotEmpty(actualValue);
            Assert.Equal(expectedValue, actualValue);
        }
Ejemplo n.º 8
0
        public void CheckTagPropertyDefaultValue()
        {
            IAppraiser appraiser = TestAppraisersCreator.CreateBasicAppraiser();

            string actualValue = appraiser.Tag;

            string expectedValue = $"Appraiser<{nameof(BasicInfo)}>";

            Assert.NotNull(actualValue);
            Assert.NotEmpty(actualValue);
            Assert.Equal(expectedValue, actualValue);
        }
Ejemplo n.º 9
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)
                );
        }
Ejemplo n.º 10
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.
                );
        }
Ejemplo n.º 11
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);
        }