Esempio n. 1
0
        public async Task ShouldCallGetCurrenciesRequestHandler()
        {
            //Arrange
            var handlerMock      = new Mock <IRequestHandler <GetCurrencies, IEnumerable <CurrencyResponse> > >();
            var expectedResponse = fixture.Create <IEnumerable <CurrencyResponse> >();

            handlerMock.Setup(m => m.SendAsync(It.IsAny <GetCurrencies>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(expectedResponse));
            var sut = new XrmOnlineManagementApiClient(new List <IPowerAppRequestHandler>()
            {
                handlerMock.Object
            });
            //Act
            var currencyResponse = await sut.GetCurrencies(CancellationToken.None);

            //Assert
            currencyResponse.Should().BeEquivalentTo(expectedResponse);
        }
Esempio n. 2
0
        public async Task ShouldCallRestoreRequestHandler()
        {
            //Arrange
            var handlerMock      = new Mock <IRequestHandler <RestoreInstanceRequest, OperationStatus> >();
            var expectedResponse = fixture.Create <OperationStatus>();

            handlerMock.Setup(m => m.SendAsync(It.IsAny <RestoreInstanceRequest>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(expectedResponse));
            var sut = new XrmOnlineManagementApiClient(new List <IPowerAppRequestHandler>()
            {
                handlerMock.Object
            });
            //Act
            var status = await sut.RestoreInstance(new RestoreInstanceRequest(Guid.NewGuid().ToString()), CancellationToken.None);

            //Assert
            status.Should().BeEquivalentTo(expectedResponse);
        }
Esempio n. 3
0
        public async Task ShouldCallGetInstanceBackupsRequestHandler()
        {
            //Arrange
            var handlerMock      = new Mock <IRequestHandler <GetInstanceBackups, GetInstanceBackupsResponse> >();
            var expectedResponse = fixture.Create <GetInstanceBackupsResponse>();

            handlerMock.Setup(m => m.SendAsync(It.IsAny <GetInstanceBackups>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(expectedResponse));
            var sut = new XrmOnlineManagementApiClient(new List <IPowerAppRequestHandler>()
            {
                handlerMock.Object
            });
            var targetInstanceId = Guid.NewGuid().ToString();
            //Act
            var status = await sut.GetInstanceBackups(new GetInstanceBackups(targetInstanceId), CancellationToken.None);

            //Assert
            status.Should().BeEquivalentTo(expectedResponse);
        }
Esempio n. 4
0
        public async Task ShouldCallCopyEnvironmentRequestHandler()
        {
            //Arrange
            var handlerMock    = new Mock <IRequestHandler <CopyRequest, OperationStatus> >();
            var expectedStatus = fixture.Create <OperationStatus>();

            handlerMock.Setup(m => m.SendAsync(It.IsAny <CopyRequest>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(expectedStatus));
            var sut = new XrmOnlineManagementApiClient(new List <IPowerAppRequestHandler>()
            {
                handlerMock.Object
            });
            var sourceInstanceId = Guid.NewGuid().ToString();
            var targetInstanceId = Guid.NewGuid().ToString();
            //Act
            var status = await sut.CopyEnvironment(new CopyRequest(sourceInstanceId, targetInstanceId, "name"), CancellationToken.None);

            //Assert
            status.Should().BeEquivalentTo(expectedStatus);
        }