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 }); }
/// <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 }); }
/// <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)) }); }