public void Retrieve_TerminalDescriptor_ProxyDataStore() { DataStoreMock .Setup(_ => _.Retrieve(TerminalDescriptor)) .Returns(Data) .Verifiable(); var result = TestInstance.Retrieve(TerminalDescriptor); DataStoreMock.Verify(); Assert.AreSame(Data, result); }
public void RetrieveAllDescriptors__TerminalDescriptorsRetrieved() { var terminalDescriptorMocks = ArraysHelper.CreateWithContent(new Mock <ITerminalDescriptor>(), new Mock <ITerminalDescriptor>()); var terminalDescriptors = terminalDescriptorMocks.Select(_ => _.Object); CompositionsMock.Setup(_ => _.RetrieveDescriptors()).Returns(new INonTerminalDescriptor[0]); DataStoreMock.Setup(_ => _.RetrieveDescriptors()).Returns(terminalDescriptors).Verifiable(); var result = (IEnumerable <IDescriptor>)ReflectionHelper.Invoke(TestInstance, "RetrieveAllDescriptors"); DataStoreMock.Verify(); Assert.IsTrue(terminalDescriptors.Equivalent(result)); }
public async void DeletingWorks() { var generator = CreateOTPGenerator(2); Target.Prepare(generator); await QRGenerationTCS.Task; Assert.True(Target.DeleteGenerator.CanExecute(null)); Target.DeleteGenerator.Execute(null); DataStoreMock.Verify(d => d.DeleteAsync(generator)); NavigatorMock.Verify(d => d.Close(Target, It.IsAny <CancellationToken>())); }
public void CreationWorks() { var generator = CreateOTPGenerator(1); Target.Label = generator.Label; Target.Issuer = generator.Issuer; Target.SecretBase32 = generator.SecretBase32; Target.AllowExporting = !AddGeneratorViewModel.AllowExportingDefault; Target.AddGenerator.Execute(null); DataStoreMock.Verify(d => d.InsertOrReplaceAsync(It.Is <OTPGenerator>( e => e.Label == generator.Label && e.Issuer == generator.Issuer && e.SecretBase32 == generator.SecretBase32 && e.AllowExporting == !AddGeneratorViewModel.AllowExportingDefault))); NavigatorMock.Verify(d => d.Close(Target, It.IsAny <CancellationToken>())); Assert.Empty(Target.Label); Assert.Empty(Target.SecretBase32); Assert.Empty(Target.Issuer); Assert.Equal(AddGeneratorViewModel.AllowExportingDefault, Target.AllowExporting); }
public void CancelingWorks() { Target.Cancel.Execute(null); DataStoreMock.Verify(d => d.InsertOrReplaceAsync(It.IsAny <OTPGenerator>()), Times.Never()); NavigatorMock.Verify(d => d.Close(Target, It.IsAny <CancellationToken>())); }