Ejemplo n.º 1
0
		public void Should_accept_the_value()
		{
			var acceptor = new Acceptor<string>(_serviceId)
			{
				Bus = _bus,
			};

			InboundMessageHeaders.SetCurrent(x =>
				{
					x.ReceivedOn(_bus);
					x.SetObjectBuilder(_builder);
					x.SetResponseAddress("loopback://localhost/queue");
				});

			Prepare<string> prepare = new Prepare<string>
				{
					BallotId = 1,
					CorrelationId = _serviceId,
					LeaderId = _leaderId,
				};

			acceptor.RaiseEvent(Acceptor<string>.Prepare, prepare);

			acceptor.CurrentState.ShouldEqual(Acceptor<string>.Prepared);

			var accept = new Accept<string>
			{
				BallotId = 1,
				CorrelationId = _serviceId,
				LeaderId = _leaderId,
				Value = "Chris",
			};

			acceptor.RaiseEvent(Acceptor<string>.Accept, accept);

			acceptor.CurrentState.ShouldEqual(Acceptor<string>.SteadyState);
			acceptor.Value.ShouldEqual(accept.Value);
			acceptor.BallotId.ShouldEqual(accept.BallotId);

			_endpoint.VerifyAllExpectations();
		}