public ContractQueryDto Add(ContractQueryDto dto) { ContractQueries.Add(dto); return(dto); }
public async Task ContractQueries() { var contractDto = new SubscriberContractDto { SubscriberId = 999, Id = 1001, Abi = "{}", Name = "StandardContract" }; //dummy values - purely to ensure the repo returns all expected values //not meant to be actually consistent with a typical record var contractQuery = new ContractQueryDto { ContractId = contractDto.Id, ContractAddress = "ContractAddress", ContractAddressParameterNumber = 2, ContractAddressSource = ContractAddressSource.EventParameter, ContractAddressStateVariableName = "ContractAddressStateVariableName", EventHandlerId = 200, EventStateOutputName = "EventStateOutputName", FunctionSignature = "FunctionSignature", SubscriptionStateOutputName = "SubscriptionStateOutputName" }; var queryParam1 = new ContractQueryParameterDto { ContractQueryId = contractQuery.EventHandlerId, EventParameterNumber = 1, Order = 1, EventStateName = "EventStateName", Id = 567, Source = EventValueSource.EventParameters, Value = "Value" }; var queryParam2 = new ContractQueryParameterDto { ContractQueryId = contractQuery.EventHandlerId, EventParameterNumber = 2, Order = 2, EventStateName = "EventStateName", Id = 568, Source = EventValueSource.EventParameters, Value = "Value" }; var queryParameterDtos = new[] { queryParam1, queryParam2 }; await Fixture.ConfigRepo.SubscriberContracts.UpsertAsync(contractDto); await Fixture.ConfigRepo.ContractQueries.UpsertAsync(contractQuery); await Fixture.ConfigRepo.ContractQueryParameters.UpsertAsync(queryParam1); await Fixture.ConfigRepo.ContractQueryParameters.UpsertAsync(queryParam2); var configFromRepo = await Fixture.ConfigRepo.EventContractQueries.GetAsync(contractDto.SubscriberId, contractQuery.EventHandlerId); Assert.Equal(contractDto.Abi, configFromRepo.Contract.Abi); Assert.Equal(contractQuery.ContractAddress, configFromRepo.Query.ContractAddress); Assert.Equal(contractQuery.ContractAddressParameterNumber, configFromRepo.Query.ContractAddressParameterNumber); Assert.Equal(contractQuery.ContractAddressSource, configFromRepo.Query.ContractAddressSource); Assert.Equal(contractQuery.ContractAddressStateVariableName, configFromRepo.Query.ContractAddressStateVariableName); Assert.Equal(contractQuery.EventStateOutputName, configFromRepo.Query.EventStateOutputName); Assert.Equal(contractQuery.FunctionSignature, configFromRepo.Query.FunctionSignature); Assert.Equal(contractQuery.SubscriptionStateOutputName, configFromRepo.Query.SubscriptionStateOutputName); Assert.Equal(queryParameterDtos.Length, configFromRepo.Parameters.Length); for (var i = 0; i < queryParameterDtos.Length; i++) { var dto = queryParameterDtos[i]; var actual = configFromRepo.Parameters[i]; Assert.Equal(dto.EventParameterNumber, actual.EventParameterNumber); Assert.Equal(dto.EventStateName, actual.EventStateName); Assert.Equal(dto.Order, actual.Order); Assert.Equal(dto.Source, actual.Source); Assert.Equal(dto.Value, actual.Value); } }