コード例 #1
0
        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.QueryReaderT("").ToList();

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
コード例 #2
0
        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.QueryReader2 <Size>("").ToList();

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
コード例 #3
0
        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.QueryReader2 <DateTime?>("").ToList();

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
コード例 #4
0
        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.QueryReader2 <int?>("").ToList();

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
コード例 #5
0
        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.QueryReader2 <TimekeeperCtor>("").ToList();

            // Assert
            actual.Should().BeEquivalentTo(data);
        }
コード例 #6
0
        public void Properties2()
        {
            // Arrange
            var data     = GenerateData(3);
            var expected = data.Select(d => new TimekeeperSimpleProp {
                Name = d.Name, Age = d.Age
            });

            var serializable = data.Select(t => new TestData.Timekeeper
            {
                Name = t.Name,
                Age  = t.Age
            }).ToList();

            var xml = Serialize(serializable);

            var service = new MockTransactionService(xml);

            // Act
            var actual = service.QueryReader2 <TimekeeperSimpleProp>("").ToList();

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }