public void PublicFieldValueConstraint() { FooMessage message = new FooMessage("my foo", "my bar"); Assert.True(PublicField.ValueConstraint("BarField", Text.Contains("bar")).Eval(message), "Returned false when supplied constraint was valid."); Assert.False(PublicField.ValueConstraint("BarField", Text.Contains("foo")).Eval(message), "Returned true when supplied constraint was invalid."); }
public async Task sut_invokes_correct_handler_method( Guid messageId, FooMessage message, string operationId, Guid correlationId, string contributor) { var mock = new Mock <MessageHandler> { CallBase = true }; MessageHandler sut = mock.Object; var envelope = new Envelope(messageId, message, operationId, correlationId, contributor); await sut.Handle(envelope, CancellationToken.None); Mock.Get(sut).Verify( x => x.Handle( It.Is <Envelope <FooMessage> >( p => p.MessageId == messageId && p.OperationId == operationId && p.CorrelationId == correlationId && p.Contributor == contributor && p.Message == message), CancellationToken.None), Times.Once()); }
public void Accepts_returns_true_if_sut_handles_message() { var message = new FooMessage(); var envelope = new Envelope(message); var sut = new MessageHandler(); bool actual = sut.Accepts(envelope); actual.Should().BeTrue(); }
private void ProcessInput() { // Begin with processing input if (System.Console.KeyAvailable) { // We have input, process accordingly var userKey = System.Console.ReadKey(); switch (userKey.Key) { case ConsoleKey.Enter: // create test message var foo = new FooMessage(); foo.FloatX = 12.98f; foo.IntY = 3985; foo.Name = "This isn't not a test!"; foo.Birthday = DateTime.Now; foo.Vector = new Vector2 { X = -9.1f, Y = 88.7f }; // for testing, print what it is Console.WriteLine("Sending to server: '" + foo.ToString() + "'"); // send test message to server this.NetworkClient.SendToServer((int)TestMessageTypes.Foo, foo); break; case ConsoleKey.Spacebar: // create test message var bar = new BarMessage(); bar.TimeOriginallySent = DateTime.Now; // for testing, print what it is Console.WriteLine("Sending to server: '" + bar.ToString() + "'"); // send test message to server this.NetworkClient.SendToServer((int)TestMessageTypes.Bar, bar); break; } } }
public void PublicFieldValueConstraint() { FooMessage message = new FooMessage("my foo", "my bar"); Assert.IsTrue(PublicField.ValueConstraint("BarField", Text.Contains("bar")).Eval(message), "Returned false when supplied constraint was valid."); Assert.IsFalse(PublicField.ValueConstraint("BarField", Text.Contains("foo")).Eval(message), "Returned true when supplied constraint was invalid."); }
static void Noop(FooMessage message) { }