Пример #1
0
        public void SetActualAsync_should_be_allowed_once()
        {
            Verifiable <int> expectation = Fake.Int();

            expectation.SetActual(() => Fake.Int());
            var ex = Assert.ThrowsAsync <InvalidOperationException>(() => expectation.SetActualAsync(() => Task.FromResult(Fake.Int())));

            Assert.That(ex.Message, Is.EqualTo("Actual value has been already specified"));
        }
Пример #2
0
        public async Task SetActualAsync_should_verify_expectation_and_update_formatting(int expected, int actual, bool shouldMatch, string message)
        {
            Verifiable <int> expectation = expected;
            await expectation.SetActualAsync(async() =>
            {
                await Task.Yield();
                return(actual);
            });

            Assert.That(expectation.Status, Is.EqualTo(shouldMatch ? ParameterVerificationStatus.Success : ParameterVerificationStatus.Failure));
            Assert.That(expectation.ToString(), Is.EqualTo(message));
        }