public async Task ChangeReleativeNTAs() { var mockRepository = new MockRepository(MockBehavior.Strict); var stockId = Guid.NewGuid(); var messageHandler = mockRepository.Create <IRestClientMessageHandler>(); messageHandler.Setup(x => x.PostAsync <ChangeRelativeNtaCommand>( It.Is <string>(x => x == "stocks/" + stockId + "/changerelativenta"), It.Is <ChangeRelativeNtaCommand>(x => x.Id == stockId && x.RelativeNtas.Count == 1))) .Returns(Task.CompletedTask) .Verifiable(); var resource = new StockResource(messageHandler.Object); var change = new ChangeRelativeNtaCommand() { Id = stockId, }; change.AddRelativeNta("XYZ", 0.50m); await resource.ChangeRelativeNTAs(change); mockRepository.Verify(); }
public void DeserializeChangeRelativeNTAsCommand() { var serializer = new RestClientSerializer(); var id = Guid.NewGuid(); var json = "{\"id\":\"" + id + "\"," + "\"changeDate\":\"2013-01-02\"," + "\"relativeNtas\":[" + "{\"childSecurity\":\"ABC\",\"percentage\":0.50}" + "]}"; var command = serializer.Deserialize <ChangeRelativeNtaCommand>(json); var expected = new ChangeRelativeNtaCommand() { Id = id, ChangeDate = new Date(2013, 01, 02), }; expected.AddRelativeNta("ABC", 0.50m); command.Should().BeEquivalentTo(expected); }