/// <inheritdoc />
        public override IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            // dummies
            var testee                    = new Testee();
            var nestedTestee              = new NestedTestee();
            var genericTesteeObject       = new GenericTestee <object>();
            var genericTesteeTestee       = new GenericTestee <Testee>();
            var genericTesteeNestedTestee = new GenericTestee <NestedTestee>();
            var listTestee                = new List <Testee>
            {
                testee, nestedTestee, genericTesteeObject, genericTesteeTestee, genericTesteeNestedTestee
            };
            var paginationTestee = new Pagination <Testee>(listTestee, 5, 2, 2);

            yield return(new object[] { testee });

            yield return(new object[] { nestedTestee });

            yield return(new object[] { genericTesteeObject });

            yield return(new object[] { genericTesteeTestee });

            yield return(new object[] { genericTesteeNestedTestee });

            yield return(new object[] { listTestee });

            yield return(new object[] { paginationTestee });
        }
Пример #2
0
        public override IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            // Guid and DateTime values shared for serialization test
            var sharedGuid     = Guid.Parse("96685bc4-dcb7-4b22-90cc-ca83baff8186");
            var sharedDateTime = DateTime.Parse("Fri, 1 May 2020 00:00:00Z");

            // dummies
            var emptyLink = new ResourceLink("", "", "");
            var testee    = new Testee {
                Id = sharedGuid, CreatedDate = sharedDateTime
            };
            var nestedTestee = new NestedTestee
            {
                Id          = sharedGuid,
                CreatedDate = sharedDateTime,
                Nested      = testee,
                Collection  = new List <Testee> {
                    testee
                }
            };
            var genericTestee = new GenericTestee <Testee>
            {
                Nested      = nestedTestee,
                Id          = sharedGuid,
                CreatedDate = sharedDateTime,
                Collection  = new List <Testee> {
                    testee, nestedTestee
                }
            };
            var testeeList = new List <Testee> {
                testee, nestedTestee, genericTestee
            };
            var testeePagination = new Pagination <Testee>(testeeList, testeeList.Count, 5);

            // resources
            var resources = testeeList.Select(x =>
            {
                var resource = new SingleResource(x);
                resource.Links.Add(emptyLink);
                return(resource);
            }).ToList();

            var enumerableResource = new EnumerableResource(resources);

            enumerableResource.Links.Add(emptyLink);
            var paginationResource = new PaginationResource(resources, resources.Count(), 5, 1);

            paginationResource.Links.Add(emptyLink);

            // expectedOutputs
            var expectedSingleString     = File.ReadAllText(Path.Combine("Serialization", "SingleResource.json"));
            var expectedEnumerableString = File.ReadAllText(Path.Combine("Serialization", "EnumerableResource.json"));
            var expectedPaginationString = File.ReadAllText(Path.Combine("Serialization", "PaginationResource.json"));

            yield return(new object[] { testee, resources.First(), expectedSingleString });

            yield return(new object[] { testeeList, enumerableResource, expectedEnumerableString });

            yield return(new object[] { testeePagination, paginationResource, expectedPaginationString });
        }
Пример #3
0
        /// <inheritdoc />
        public override IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            var testee        = new Testee();
            var nestedTestee  = new NestedTestee();
            var genericTestee = new GenericTestee <Testee> {
                Nested = testee, Collection = new List <Testee> {
                    testee
                }
            };

            yield return(new object[] { testee, new Func <Testee, bool>(x => x.BoolValue) });

            yield return(new object[] { testee, new Func <Testee, bool>(x => x.DecimalValue > 2000m) });

            yield return(new object[] { testee, new Func <Testee, bool>(x => !string.IsNullOrWhiteSpace(x.StringValue)) });

            yield return(new object[] { testee, new Func <Testee, bool>(x => x.DecimalValue == new decimal(x.FloatValue)) });

            yield return(new object[] { nestedTestee, new Func <NestedTestee, bool>(x => x.Nested.BoolValue) });

            yield return(new object[] { nestedTestee, new Func <NestedTestee, bool>(x => x.Nested.DecimalValue > 2000m) });

            yield return(new object[]
            {
                nestedTestee, new Func <NestedTestee, bool>(x => !string.IsNullOrWhiteSpace(x.Nested.StringValue))
            });

            yield return(new object[]
            {
                nestedTestee, new Func <NestedTestee, bool>(x => x.DecimalValue == new decimal(x.Nested.FloatValue))
            });

            yield return(new object[]
            {
                genericTestee,
                new Func <GenericTestee <Testee>, bool>(x => x.Collection.First().BoolValue)
            });

            yield return(new object[]
            {
                genericTestee, new Func <GenericTestee <Testee>, bool>(x => x.Collection.First().DecimalValue > 2000m)
            });

            yield return(new object[]
            {
                genericTestee,
                new Func <GenericTestee <Testee>, bool>(x => !string.IsNullOrWhiteSpace(x.Collection.First().StringValue))
            });

            yield return(new object[]
            {
                genericTestee,
                new Func <GenericTestee <Testee>, bool>(x => x.Collection.First().DecimalValue == new decimal(x.FloatValue))
            });
        }
Пример #4
0
        public void Equals(bool left, bool right, bool expected)
        {
            var first = new Testee {
                Value = left
            };
            var second = new Testee {
                Value = right
            };

            Assert.That(Emitted.Equals(first, second), Is.EqualTo(expected));
        }
Пример #5
0
        public void GetApplicableLinks_WithNotConfiguredType_ReturnEmptyList(Testee instance)
        {
            // arrange
            var notConfiguredType = instance.GetType();

            // act
            var hateoasLinks = _sut.GetApplicableLinks(notConfiguredType, instance);

            // assert
            Assert.IsType <List <IHateoasLink> >(hateoasLinks);
            Assert.Empty(hateoasLinks);
        }
        public override IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            var testee     = new Testee();
            var listTestee = new List <Testee> {
                testee
            };
            var paginationTestee = new Pagination <Testee>(listTestee, 1, 10);

            var singleResources     = listTestee.Select(x => new SingleResource(x)).ToList();
            var enumerableResource  = new EnumerableResource(singleResources);
            var paginationResources = new PaginationResource(singleResources, 1, 10, 1);

            yield return(new object[] { new SingleResource(testee), testee, typeof(Testee) });                         //,(Testee) null};

            yield return(new object[] { enumerableResource, listTestee, typeof(List <Testee>) });                      //, testee};

            yield return(new object[] { paginationResources, paginationTestee, typeof(Pagination <Testee>) });         //, testee};
        }
Пример #7
0
 public void Equals(long left, long right, bool expected)
 {
     var first = new Testee { Value = left };
     var second = new Testee { Value = right };
     Assert.That(Emitted.Equals(first, second), Is.EqualTo(expected));
 }
Пример #8
0
        public void GetRouteDictionary_And_HasRouteDataParameterFunction_ReturnsSameValue(Testee testee)
        {
            // act
            var hateoasLink = _fixture.Sut.HasRouteData(x => new { id = x.LongIntegerValue, label = x.StringValue });
            var expected = new { id = testee.LongIntegerValue, label = testee.StringValue }.ToRouteDictionary();
            var actual = _fixture.Sut.GetRouteDictionary(testee);

            // assert
            Assert.Same(_fixture.Sut, hateoasLink);
            Assert.Equal(expected, actual);
        }
Пример #9
0
 public void SunnyDay()
 {
     CollectionTestUtils.VerifyData <T>(BackCollection, Testee);
     Assert.IsFalse(Testee.Contains(TheTestItem1));
 }
Пример #10
0
 public void RemoveIsNotSupported()
 {
     Testee.Remove(TheTestItem1);
 }
Пример #11
0
 public void ClearIsNotSupported()
 {
     Testee.Clear();
 }
Пример #12
0
 public void AddIsNotSupported()
 {
     Testee.Add(TheTestItem1);
 }