public async Task <GetCurrentVersionResponse> Handle(GetCurrentVersionRequest request, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(request, nameof(request));

            List <CurrentVersionInformation> currentVersions = await _schemaDataStore.GetCurrentVersionAsync(cancellationToken);

            return(new GetCurrentVersionResponse(currentVersions));
        }
Beispiel #2
0
        public async Task GivenACurrentMediator_WhenCurrentRequest_ThenReturnsCurrentVersionInformation()
        {
            string status = "completed";

            var mockCurrentVersions = new List <CurrentVersionInformation>()
            {
                new CurrentVersionInformation(1, (SchemaVersionStatus)Enum.Parse(typeof(SchemaVersionStatus), status, true), new List <string>()
                {
                    "server1", "server2"
                }),
                new CurrentVersionInformation(2, (SchemaVersionStatus)Enum.Parse(typeof(SchemaVersionStatus), status, true), new List <string>()),
            };

            _schemaDataStore.GetCurrentVersionAsync(Arg.Any <CancellationToken>())
            .Returns(mockCurrentVersions);
            GetCurrentVersionResponse response = await _mediator.GetCurrentVersionAsync(_cancellationToken);

            var currentVersionsResponse = response.CurrentVersions;

            Assert.Equal(mockCurrentVersions.Count, currentVersionsResponse.Count);
            Assert.Equal(1, currentVersionsResponse[0].Id);
            Assert.Equal(SchemaVersionStatus.Completed, currentVersionsResponse[0].Status);
            Assert.Equal(2, currentVersionsResponse[0].Servers.Count);
        }