public async Task ShouldUpdateNativeDesktopAdditionalInformationAndNothingElse() { var clientApplication = new Application.Domain.ClientApplication { NativeDesktopAdditionalInformation = "Some old info" }; var clientJson = JsonConvert.SerializeObject(clientApplication); SetUpMockSolutionRepositoryGetByIdAsync(clientJson); var calledBack = false; Context.MockSolutionDetailRepository .Setup(r => r.UpdateClientApplicationAsync(It.IsAny <IUpdateSolutionClientApplicationRequest>(), It.IsAny <CancellationToken>())) .Callback((IUpdateSolutionClientApplicationRequest updateSolutionClientApplicationRequest, CancellationToken cancellationToken) => { calledBack = true; var json = JToken.Parse(updateSolutionClientApplicationRequest.ClientApplication); var newClientApplication = JsonConvert.DeserializeObject <Application.Domain.ClientApplication>(json.ToString()); clientApplication.Should().BeEquivalentTo(newClientApplication, c => c.Excluding(m => m.NativeDesktopAdditionalInformation)); newClientApplication.NativeDesktopAdditionalInformation.Should().Be("Some new info"); }); var validationResult = await UpdateNativeDesktopAdditionalInformation("Some new info").ConfigureAwait(false); validationResult.IsValid.Should().BeTrue(); Context.MockSolutionRepository.Verify(r => r.ByIdAsync(SolutionId, It.IsAny <CancellationToken>()), Times.Once()); calledBack.Should().BeTrue(); }
public async Task ShouldUpdateSolutionNativeDesktopThirdPartyAndNothingElse() { var clientApplication = new Application.Domain.ClientApplication { NativeDesktopThirdParty = new NativeDesktopThirdParty { ThirdPartyComponents = "Component", DeviceCapabilities = "Capabilities", }, }; var clientJson = JsonConvert.SerializeObject(clientApplication); SetUpMockSolutionRepositoryGetByIdAsync(clientJson); var calledBack = false; void Action(IUpdateSolutionClientApplicationRequest request, CancellationToken token) { calledBack = true; var json = JToken.Parse(request.ClientApplication); var newClientApplication = JsonConvert.DeserializeObject <Application.Domain.ClientApplication>(json.ToString()); clientApplication.Should().BeEquivalentTo(newClientApplication, c => c.Excluding(m => m.NativeDesktopThirdParty)); newClientApplication.NativeDesktopThirdParty.ThirdPartyComponents.Should().Be("New Component"); newClientApplication.NativeDesktopThirdParty.DeviceCapabilities.Should().Be("New Capability"); } Context.MockSolutionRepository .Setup(r => r.UpdateClientApplicationAsync( It.IsAny <IUpdateSolutionClientApplicationRequest>(), It.IsAny <CancellationToken>())) .Callback <IUpdateSolutionClientApplicationRequest, CancellationToken>(Action); var validationResult = await UpdateNativeDesktopThirdParty("New Component", "New Capability"); validationResult.IsValid.Should().BeTrue(); Context.MockSolutionRepository.Verify(r => r.ByIdAsync(SolutionId, It.IsAny <CancellationToken>())); calledBack.Should().BeTrue(); }
public async Task ShouldUpdateSolutionNativeMobileHardwareRequirementAndNothingElse() { var clientApplication = new Application.Domain.ClientApplication { NativeDesktopHardwareRequirements = "initialHardwareRequirements", }; var clientJson = JsonConvert.SerializeObject(clientApplication); SetUpMockSolutionRepositoryGetByIdAsync(clientJson); var calledBack = false; void Action(IUpdateSolutionClientApplicationRequest request, CancellationToken token) { calledBack = true; var json = JToken.Parse(request.ClientApplication); var newClientApplication = JsonConvert.DeserializeObject <Application.Domain.ClientApplication>( json.ToString()); clientApplication.Should().BeEquivalentTo( newClientApplication, c => c.Excluding(m => m.NativeDesktopHardwareRequirements)); newClientApplication.NativeDesktopHardwareRequirements.Should().Be("Updated hardware"); } Context.MockSolutionRepository .Setup(r => r.UpdateClientApplicationAsync( It.IsAny <IUpdateSolutionClientApplicationRequest>(), It.IsAny <CancellationToken>())) .Callback <IUpdateSolutionClientApplicationRequest, CancellationToken>(Action); var validationResult = await UpdateNativeDesktopHardwareRequirements("Updated hardware"); validationResult.IsValid.Should().BeTrue(); Context.MockSolutionRepository.Verify(r => r.ByIdAsync(SolutionId, It.IsAny <CancellationToken>())); calledBack.Should().BeTrue(); }