示例#1
0
        public async Task <ComplexObjectTest> ComplexUnrelatedCallAsync(ComplexObjectTest input)
        {
            await Task.Delay(1);

            ComplexUnrelatedCallCount++;
            return(input);
        }
        public void CorrectlySerializesComplexObject()
        {
            string fileName = $"{nameof(CorrectlySerializesComplexObject)}.json";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            var testCounter = new TestCounter();

            var complexObject = new ComplexObjectTest()
            {
                Age   = new DateTime(2014, 1, 6),
                Name  = "Devedse123",
                Timer = 400
            };

            var lss1    = new LineStateSaver(fileName);
            var result1 = lss1.Save(() => testCounter.ComplexCall(complexObject));

            var lss2    = new LineStateSaver(fileName);
            var result2 = lss2.Save(() => testCounter.ComplexCall(complexObject));

            Assert.Equal(result1, result2);
            Assert.Equal(1, testCounter.CallCount);

            File.Delete(fileName);
        }
        public void OnlyCallsMethodOncePerComplexObject()
        {
            var testCounter = new TestCounter();

            var complexObject1 = new ComplexObjectTest()
            {
                Age   = new DateTime(2018, 5, 2),
                Name  = "Devedse",
                Timer = 600
            };

            var complexObject2 = new ComplexObjectTest()
            {
                Age   = new DateTime(2018, 5, 2),
                Name  = "Devedse",
                Timer = 601
            };

            var lss = new LineStateSaver();

            lss.Save(() => testCounter.ComplexCall(complexObject1));
            lss.Save(() => testCounter.ComplexCall(complexObject1));
            lss.Save(() => testCounter.ComplexCall(complexObject2));
            lss.Save(() => testCounter.ComplexCall(complexObject1));
            lss.Save(() => testCounter.ComplexCall(complexObject1, complexObject2));
            lss.Save(() => testCounter.ComplexUnrelatedCall(complexObject2));

            Assert.Equal(2, testCounter.CallCount);
            Assert.Equal(1, testCounter.DoubleParametersCallCount);
            Assert.Equal(1, testCounter.ComplexUnrelatedCallCount);
        }
示例#4
0
        public ComplexObjectTest ComplexCall(ComplexObjectTest input, ComplexObjectTest input2)
        {
            DoubleParametersCallCount++;

            var retval = new ComplexObjectTest()
            {
                Age   = input.Age.AddDays(5).AddDays(input2.Age.Day),
                Name  = input.Name + "blah" + input2.Name,
                Timer = input.Timer + 100 + input2.Timer
            };

            return(retval);
        }
示例#5
0
        public ComplexObjectTest ComplexCall(ComplexObjectTest input)
        {
            CallCount++;

            var retval = new ComplexObjectTest()
            {
                Age   = input.Age.AddDays(5),
                Name  = input.Name + "blah",
                Timer = input.Timer + 100
            };

            return(retval);
        }
示例#6
0
        public async Task <ComplexObjectTest> ComplexCallAsync(ComplexObjectTest input)
        {
            await Task.Delay(1);

            CallCount++;

            var retval = new ComplexObjectTest()
            {
                Age   = input.Age.AddDays(5),
                Name  = input.Name + "blah",
                Timer = input.Timer + 100
            };

            return(retval);
        }
示例#7
0
        public async Task <ComplexObjectTest> ComplexCallAsync(ComplexObjectTest input, ComplexObjectTest input2)
        {
            await Task.Delay(1);

            DoubleParametersCallCount++;

            var retval = new ComplexObjectTest()
            {
                Age   = input.Age.AddDays(5).AddDays(input2.Age.Day),
                Name  = input.Name + "blah" + input2.Name,
                Timer = input.Timer + 100 + input2.Timer
            };

            return(retval);
        }
示例#8
0
 public ComplexObjectTest ComplexUnrelatedCall(ComplexObjectTest input)
 {
     ComplexUnrelatedCallCount++;
     return(input);
 }