public void QueryDict() { // Arrange var data = GenerateData(3); var expected = data.Select(d => { return(new Dictionary <string, string> { { nameof(d.Name), d.Name }, { nameof(d.Age), d.Age.ToString() }, { nameof(d.DateOfBirth), d.DateOfBirth?.ToString("yyyy-MM-dd") } }); }); var serializable = data.Select(v => new TestData.Timekeeper { Name = v.Name, Age = v.Age, DateOfBirth = v.DateOfBirth?.ToString("yyyy-MM-dd") ?? "" }).ToList(); var xml = Serialize(serializable); var service = new MockTransactionService(xml); // Act var actual = service.QueryT("").ToList(); // Assert actual.Should().BeEquivalentTo(expected); }
public void QueryEnum(IEnumerable <Size> sizes) { // Arrange var expected = sizes; var serializable = sizes.Select(v => new TestData.SingleValueRow { Value = ((int)v).ToString() }).ToList(); var xml = Serialize(serializable); var service = new MockTransactionService(xml); // Act var actual = service.Query2 <Size>("").ToList(); // Assert actual.Should().BeEquivalentTo(expected); }
public void QueryNullableDateTime() { // Arrange var data = GenerateData(3); var expected = data.Select(d => d.DateOfBirth); var serializable = data.Select(t => new TestData.SingleValueRow { Value = t.DateOfBirth?.ToString("yyyy-MM-dd") ?? "" }).ToList(); var xml = Serialize(serializable); var service = new MockTransactionService(xml); // Act var actual = service.Query2 <DateTime?>("").ToList(); // Assert actual.Should().BeEquivalentTo(expected); }
public void QueryNullableInt() { // Arrange var data = GenerateData(3); var expected = data.Select(d => (int?)d.Age); var serializable = data.Select(t => new TestData.Timekeeper { Age = t.Age }).ToList(); var xml = Serialize(serializable); var service = new MockTransactionService(xml); // Act var actual = service.Query2 <int?>("").ToList(); // Assert actual.Should().BeEquivalentTo(expected); }
public void QueryString() { // Arrange var data = GenerateData(3); var expected = data.Select(d => d.Name); var serializable = data.Select(t => new TestData.Timekeeper { Name = t.Name }).ToList(); var xml = Serialize(serializable); var service = new MockTransactionService(xml); // Act var actual = service.Query2 <string>("").ToList(); // Assert actual.Should().BeEquivalentTo(expected); }
public void Constructor3() { // Arrange var data = GenerateData(3); var serializable = data.Select(t => new TestData.Timekeeper { Name = t.Name, Age = t.Age, DateOfBirth = t.DateOfBirth?.ToString("yyyy-MM-dd") ?? "", MatterNumber = t.MatterNumber?.ToString() ?? "" }).ToList(); var xml = Serialize(serializable); var service = new MockTransactionService(xml); // Act var actual = service.Query2 <TimekeeperCtor>("").ToList(); // Assert actual.Should().BeEquivalentTo(data); }