Exemplo n.º 1
0
        public async Task CanInsertAndGetData(int id, string comment, double doubleValue)
        {
            var expected = new TestDataEntry(id, comment, doubleValue);
            await sut.BatchUploadAsync(
                new[] { expected },
                TableName,
                new[] { nameof(TestDataEntry.Id), nameof(TestDataEntry.Comment), nameof(TestDataEntry.DoubleValue) },
                x => new[] { new[] { x.Id.ToString(), x.Comment, x.DoubleValue.ToString("F2", CultureInfo.InvariantCulture) } });

            var readData = new List <TestDataEntry>();
            await sut.BuildResultAsync($"SELECT * FROM {TableName}", reader =>
            {
                var id          = SqlHelpers.ReadInt(reader, nameof(TestDataEntry.Id));
                var comment     = SqlHelpers.ReadString(reader, nameof(TestDataEntry.Comment));
                var doubleValue = SqlHelpers.ReadDouble(reader, nameof(TestDataEntry.DoubleValue));

                readData.Add(new TestDataEntry(id.Value, comment, doubleValue.Value));
            });

            Assert.That(readData.Count, Is.EqualTo(1));
            var actual = readData.Single();

            Assert.That(actual.Id, Is.EqualTo(expected.Id));
            Assert.That(actual.Comment, Is.EqualTo(expected.Comment));
            Assert.That(actual.DoubleValue, Is.EqualTo(expected.DoubleValue).Within(1e-6));
        }
Exemplo n.º 2
0
        public void When_setting_flags_directly(TestDataEntry <byte, Intel8080FlagsRegister> test)
        {
            Subject.Sign           = test.Expected.Sign;
            Subject.Zero           = test.Expected.Zero;
            Subject.Flag5          = test.Expected.Flag5;
            Subject.HalfCarry      = test.Expected.HalfCarry;
            Subject.Flag3          = test.Expected.Flag3;
            Subject.ParityOverflow = test.Expected.ParityOverflow;
            Subject.Subtract       = test.Expected.Subtract;
            Subject.Carry          = test.Expected.Carry;

            Subject.Register.ShouldBe(test.Value);
        }
Exemplo n.º 3
0
        private void AssertSubject(TestDataEntry <byte, Intel8080FlagsRegister> test)
        {
            var assertions = GetAssertions(test.Expected, Subject).ToArray();

            Subject.ShouldSatisfyAllConditions(test.ToString(), assertions);
        }
Exemplo n.º 4
0
 public void When_setting_flags_via_register(TestDataEntry <byte, Intel8080FlagsRegister> test)
 {
     Subject.Register = test.Value;
     AssertSubject(test);
 }
Exemplo n.º 5
0
 public void When_setting_parity_flags(TestDataEntry <byte, Intel8080FlagsRegister> test)
 {
     Subject.SetParityFlags(test.Value);
     AssertSubject(test);
 }
Exemplo n.º 6
0
 public void When_setting_undocumented_flags(TestDataEntry <byte, Intel8080FlagsRegister> test)
 {
     Subject.SetUndocumentedFlags(test.Value);
     AssertSubject(test);
 }