/// <summary> /// Create a new TestOperation object. /// </summary> /// <param name="ID">Initial value of Id.</param> public static TestOperation CreateTestOperation(int ID) { TestOperation testOperation = new TestOperation(); testOperation.Id = ID; return(testOperation); }
static void Main(string[] args) { Dictionary <long, int> results = new Dictionary <long, int>(); var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); QArray <bool> bits = new QArray <bool>() { true, false, true, true, true }; for (int i = 0; i < 2048; i++) { long result = TestOperation.Run(sim, bits).Result; if (results.ContainsKey(result)) { results[result]++; } else { results[result] = 1; } } foreach (KeyValuePair <long, int> result in results) { Console.WriteLine($"{Convert.ToString(result.Key, 2), 3} - {result.Value}"); } Console.Read(); }
public void RunAsync_OnFailureOperation_NotBlockExecutionAndReturnsOperationGuidAndOperationsManagerStatusThrows_Test() { var operationsManager = new OperationsManagerMock(); var operation = new TestOperation(operationsManager, isFailure: true); var startTime = DateTime.Now; var enqueuedToken = operation.RunAsync(); var endTime = DateTime.Now; var beforeWaitOperationStatus = operationsManager.GetOperationStatus(enqueuedToken.OperationId); Thread.Sleep(TestOperation.OperationDuration + TestOperation.SafeTimeToSetOperationResult); Exception exception = null; try { operationsManager.GetOperationStatus(enqueuedToken.OperationId); } catch (Exception ex) { exception = ex; } Assert.IsTrue(endTime - startTime < TestOperation.OperationDuration); Assert.AreEqual(OperationState.Started, beforeWaitOperationStatus.Info.State); Assert.IsNull(beforeWaitOperationStatus.Result); Assert.AreEqual(TestOperation.OperationException, exception); }
public void TestWeightedSequentialExecution() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue <TestOperation> testQueueOperation = new OperationQueue <TestOperation>( new WeightedTransaction <TestOperation>[] { new WeightedTransaction <TestOperation>(operation1, 0.5f), new WeightedTransaction <TestOperation>(operation2, 2.0f) } ); Mock <IOperationQueueSubscriber> mockedSubscriber = mockSubscriber(testQueueOperation); testQueueOperation.Start(); mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With( new NMock.Matchers.TypeMatcher(typeof(OperationQueue <TestOperation>)), new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.1f)) ); operation1.ChangeProgress(0.5f); mockedSubscriber.Expects.One.Method(m => m.ProgressChanged(null, null)).With( new NMock.Matchers.TypeMatcher(typeof(OperationQueue <TestOperation>)), new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.2f)) ); operation1.SetEnded(); this.mockery.VerifyAllExpectationsHaveBeenMet(); }
static void Main(string[] args) { var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); for (int state = 0; state < 4; state++) { //Dictionary<long, int> results = new Dictionary<long, int>(); //for (int i = 0; i < 2048; i++) //{ // long result = TestGenerate.Run(sim, state).Result; // if (results.ContainsKey(result)) // results[result]++; // else // results[result] = 1; //} //Console.WriteLine($"{state}:"); //foreach (KeyValuePair<long, int> result in results) // Console.WriteLine($" {LeadingZeros(Convert.ToString(result.Key, 2), 2)} - {result.Value / 2048m}"); //Console.WriteLine(); Console.WriteLine($"{state} - {TestOperation.Run(sim, state).Result}"); } Console.Read(); }
static void Main(string[] args) { var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); Random rnd = new Random(); for (int j = 0; j < 10; j++) { Dictionary <long, int> results = new Dictionary <long, int>(); int int0 = rnd.Next(0, 256); int int1 = rnd.Next(0, 256); string bitString0 = Convert.ToString(int0, 2); string bitString1 = Convert.ToString(int1, 2); int length = Math.Max(bitString0.Length, bitString1.Length); bitString0 = LeadingZeros(bitString0, length); bitString1 = LeadingZeros(bitString1, length); Console.WriteLine($"{bitString0} {bitString1}"); QArray <bool> bitArray0 = new QArray <bool>(); QArray <bool> bitArray1 = new QArray <bool>(); foreach (char bit in bitString0.ToCharArray().Reverse()) { bitArray0.Add(bit == '1'); } foreach (char bit in bitString1.ToCharArray().Reverse()) { bitArray1.Add(bit == '1'); } for (int i = 0; i < 2048; i++) { long result = TestOperation.Run(sim, bitArray0, bitArray1).Result; if (results.ContainsKey(result)) { results[result]++; } else { results[result] = 1; } } foreach (KeyValuePair <long, int> result in results) { Console.Write($"{LeadingZeros(Convert.ToString(result.Key, 2), bitString0.Length)} "); } Console.WriteLine("\n"); } Console.Read(); }
public void QuantumSimulatorTarget(TestOperation operationDescription) { try { using (var sim = new QuantumSimulator()) { // Frequently tests include measurement and randomness. // To reproduce the failed test it is useful to record seed that has been used // for the random number generator inside the simulator. output.WriteLine($"The seed used for this test is {sim.Seed}"); Debug.WriteLine($"The seed used for this test is {sim.Seed}"); // This ensures that when the test is run in Debug mode, all message logged in // Q# by calling Microsoft.Quantum.Primitives.Message show-up // in Debug output sim.OnLog += (string message) => { Debug.WriteLine(message); }; // this ensures that all message logged in Q# by calling // Microsoft.Quantum.Primitives.Message show-up // in test output sim.OnLog += (string message) => { output.WriteLine(message); }; // Executes operation described by operationDescription on a QuantumSimulator operationDescription.TestOperationRunner(sim); } } catch (System.BadImageFormatException e) { throw new System.BadImageFormatException($"Could not load Quantum Simulator. If you are running tests using Visual Studio 2017, " + $"this problem can be fixed by using menu Test > Test Settings > Default Processor Architecture " + $"and switching to X64 instead of X86. Alternatively, press Ctrl+Q and type `Default Processor Architecture`. If you are running from command line using " + $"vstest.console.exe use command line option /Platform:x64.", e); } }
public void TestOperationStarting() { TestOperation myOperation = new TestOperation(); Assert.IsFalse(myOperation.Ended); myOperation.Start(); Assert.IsTrue(myOperation.Ended); }
public void QuantumSimulatorOldCanonTarget(TestOperation opData) { // It is convenient to store seed for test that can fail with small probability uint?seed = RetriveStoredSeed(opData); using (var sim = new QuantumSimulator(randomNumberGeneratorSeed: seed)) { #if DEBUG // Frequently tests include measurement and randomness. // To reproduce the failed test it is useful to record seed that has been used // for the random number generator inside the simulator. LogSimulatorSeed(opData, sim); // This ensures that when the test is run in Debug mode, all message logged in // Q# by calling Microsoft.Quantum.Primitives.Message show-up // in Debug output sim.OnLog += (string message) => { Debug.WriteLine(message); }; // this ensures that all message logged in Q# by calling // Microsoft.Quantum.Primitives.Message show-up // in test output sim.OnLog += (string message) => { output.WriteLine(message); }; // executes operation opData.TestOperationRunner(sim); #else throw new System.Exception("Tests should be removed from Microsoft.Quantum.Canon.dll."); #endif } }
public void QSimTestTarget(TestOperation op) { using (var sim = new QuantumSimulator()) { OverrideOperation < ICallable <(Qubit, Qubit), QVoid>, Simulators.QCTraceSimulators.Implementation.Interface_CX, Intrinsic.CNOT>(sim); OverrideOperation < ICallable <(Pauli, Int64, Int64, Qubit), QVoid>, Simulators.QCTraceSimulators.Implementation.Interface_RFrac, Intrinsic.RFrac>(sim); OverrideOperation < ICallable <(Pauli, Double, Qubit), QVoid>, Simulators.QCTraceSimulators.Implementation.Interface_R, Intrinsic.R>(sim); OverrideOperation < ICallable <(Int64, Pauli, Qubit), QVoid>, Simulators.QCTraceSimulators.Implementation.Interface_Clifford, Interface_Clifford>(sim); sim.OnLog += (msg) => { output.WriteLine(msg); }; sim.OnLog += (msg) => { Debug.WriteLine(msg); }; op.TestOperationRunner(sim); } }
public void Serialization_OperationSerialized_DeserializedProperly(TestOperation operation) { var serializedOperation = SerializeOperation(operation); var deserializedOperation = DeserializeOperation <TestOperation>(serializedOperation); Assert.That(deserializedOperation, Is.EqualTo(operation)); }
public int IncrementLog(string desc) { TestOperation to = new TestOperation { Date = DateTime.Now, Name = desc }; this.CurrentDataSource.AddObject("TestOperations", to); this.CurrentDataSource.SaveChanges(); return to.Id; }
public void QuantumSimulatorTargetShouldFail(TestOperation opData) { // It is convenient to store seed for test that can fail with small probability uint?seed = RetriveStoredSeed(opData); using (var sim = new QuantumSimulator(randomNumberGeneratorSeed: seed)) { // Frequently tests include measurement and randomness. // To reproduce the failed test it is useful to record seed that has been used // for the random number generator inside the simulator. LogSimulatorSeed(opData, sim); // This ensures that when the test is run in Debug mode, all message logged in // Q# by calling Microsoft.Quantum.Primitives.Message show-up // in Debug output sim.OnLog += (string message) => { Debug.WriteLine(message); }; // this ensures that all message logged in Q# by calling // Microsoft.Quantum.Primitives.Message show-up // in test output sim.OnLog += (string message) => { output.WriteLine(message); }; // executes operation and expects and exception from Q# Assert.ThrowsAny <ExecutionFailException>(() => opData.TestOperationRunner(sim)); } }
private static ValidateDateComesBefore CreateValidator(TestOperation operation) { return(new ValidateDateComesBefore { ToCompare = operation.LaterDate }); }
public void QrackSimTestTarget(TestOperation op) { using (var sim = new QrackSimulator(throwOnReleasingQubitsNotInZeroState: true)) { op.TestOperationRunner(sim); } }
public void QuantumTestSuiteSelfTests(TestOperation op) { var sim = new TrivialSimulator(); //these tests do not do anything quantum sim.OnLog += (msg) => { output.WriteLine(msg); }; op.TestOperationRunner(sim); }
public void ExecuteTwoOperationsOfDifferentTypes() { var op1HasExecuted = false; var op1 = new TestOperation <object, int>("Operation #1", input => { var results = SlowEnumerable(5, TimeSpan.FromSeconds(0.1)); op1HasExecuted = true; return(results); }); var op2HasExecuted = false; var op2 = new TestOperation <int, string>("Operation #2", input => { var results = input.Select(i => i + 1).Select(i => i.ToString()); op2HasExecuted = true; return(results); }); var pipeline = CreateNewPipeline(); pipeline.AddOperation(op1); pipeline.AddOperation(op2); pipeline.Execute(); op1HasExecuted.ShouldBeTrue(); op2HasExecuted.ShouldBeTrue(); }
public void QrackSimTestTarget(TestOperation op) { using (var sim = new QrackSimulator(throwOnReleasingQubitsNotInZeroState: true)) { sim.OnLog += (msg) => { output.WriteLine(msg); }; op.TestOperationRunner(sim); } }
public void Operations_do_not_have_any_child_operations_by_default() { var sut = new TestOperation(); var result = sut.GetChildOperations(); Assert.False(result.Any()); }
/// <summary> /// Executes a quantum test operation. /// </summary> /// <param name="Operation">The operation to run</param> private void RunTest(TestOperation Operation) { using (QuantumSimulator simulator = new QuantumSimulator()) { simulator.OnLog += HandleTestLogMessage; Operation.TestOperationRunner(simulator); } }
//[OperationDriver(TestCasePrefix = "QSim:", TestNamespace = "Microsoft.Quantum.Simulation.TestSuite.VeryLong")] private void QSimTestTargetVeryLong(TestOperation op) { using (var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true)) { sim.OnLog += (msg) => { output.WriteLine(msg); }; op.TestOperationRunner(sim); } }
public void QSimTests(TestOperation op) { var sim = new QuantumSimulator(); // OnLog defines action(s) performed when Q# test calls function Message sim.OnLog += (msg) => { output.WriteLine(msg); }; sim.OnLog += (msg) => { Debug.WriteLine(msg); }; op.TestOperationRunner(sim); }
public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel, InstanceContext instanceContext) { Uri originalURI = null; if (request.Properties.ContainsKey("OriginalHttpRequestUri")) { originalURI = request.Properties["OriginalHttpRequestUri"] as Uri; } else { //When running in WCF ServiceHost mode , the OriginalHttpRequestUri is inaccissible as the host does not support it originalURI = request.Properties.Via; } #region Log only interesting operations string lastSegment = originalURI.Segments.Last(); if (ignorePoints.Any(fo => lastSegment.Contains(fo))) { return(null); } #endregion HttpRequestMessageProperty httpmsg = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name]; if (httpmsg != null && httpmsg.Headers != null && httpmsg.Headers.AllKeys.Contains(LogIndexHeader)) { PTEntities ctx = new PTEntities(); int LogIndex; if (!Int32.TryParse(httpmsg.Headers[LogIndexHeader], out LogIndex)) { return(null); } TestOperation t = ctx.TestOperations.FirstOrDefault(to => (to.Id == LogIndex)); if (t == null) { return(null); } LogEntry le = new LogEntry { TestOperation = t, URI = originalURI.ToString(), Verb = httpmsg.Method }; ctx.AddObject("LogEntries", le); // skip loging of the logIndex header foreach (var key in httpmsg.Headers.AllKeys.Where(k => !k.Equals(LogIndexHeader, StringComparison.OrdinalIgnoreCase))) { ctx.AddObject("LogEntryHeaders", new LogEntryHeader { LogEntry = le, Header = key, Value = httpmsg.Headers[key] }); } ctx.SaveChanges(); return(new MyCorrelation { Uri = originalURI, LogIndex = httpmsg.Headers[LogIndexHeader] }); } return(null); }
public void TestTarget(TestOperation op) { var sim = new ToffoliSimulator(); // OnLog defines action(s) performed when Q# test calls function Message sim.OnLog += (msg) => { this.output.WriteLine(msg); }; sim.OnLog += (msg) => { Debug.WriteLine(msg); }; op.TestOperationRunner(sim); }
public void ShouldMerge() { var op = new TestOperation(); var otherOp = new TestOperation(); op.Merge(otherOp); Assert.That(op.MergeCalled, Is.True); Assert.That(op.OtherOperation, Is.SameAs(otherOp)); }
public void ShouldRegisterOperation() { var manager = new ActiveOperationsManager(); var operation = new TestOperation(); var promise = manager.RegisterOperation(operation); manager.ActiveOperations.ShouldContain(operation); promise.ShouldBeOfType <OperationPromise <TestResponse> >(); }
/// <summary> /// Logs the seed used for the test run /// </summary> private void LogSimulatorSeed(TestOperation opData, QuantumSimulator sim) { // Frequently tests include measurement and randomness. // To reproduce the failed test it is useful to record seed that has been used // for the random number generator inside the simulator. string msg = $"The seed, operation pair is (\"{ opData.fullClassName}\",{ sim.Seed})"; output.WriteLine(msg); Debug.WriteLine(msg); }
public int IncrementLog(string desc) { TestOperation to = new TestOperation { Date = DateTime.Now, Name = desc }; this.CurrentDataSource.AddObject("TestOperations", to); this.CurrentDataSource.SaveChanges(); return(to.Id); }
public void TestTarget(TestOperation op) { using (var sim = new CounterSimulator()) { // OnLog defines action(s) performed when Q# test calls function Message sim.OnLog += (msg) => { output.WriteLine(msg); }; sim.OnLog += (msg) => { Debug.WriteLine(msg); }; op.TestOperationRunner(sim); } }
public void TestGaussianElimination(TestOperation op) { using (var sim = new QuantumSimulator()) { // OnLog defines action(s) performed when Q# test calls function Message sim.OnLog += (msg) => { output.WriteLine(msg); }; sim.OnLog += (msg) => { Debug.WriteLine(msg); }; op.TestOperationRunner(sim); } }
public void ShouldMergeIfOtherOperationDisabled() { var op = new TestOperation(); var otherOp = new TestOperation { Disabled = true }; op.Merge(otherOp); Assert.That(op.MergeCalled, Is.True); }
public void ShouldNotMergeIfReceivingOperationDisabled() { var op = new TestOperation { Disabled = true }; var otherOp = new TestOperation(); op.Merge(otherOp); Assert.That(op.MergeCalled, Is.False); }
public void Should_determine_first_date_is_before_later_date_when_later_date_has_time_and_dates_are_equal() { var operation = new TestOperation { EarlierDate = new DateTime(2008, 4, 15, 0, 0, 0), LaterDate = new DateTime(2008, 4, 15, 8, 30, 0) }; ValidateDateComesBefore rule = CreateValidator(operation); string result = rule.IsValid(operation.EarlierDate); Assert.Null(result); }
public void RunSync_OnSuccessfulOperation_BlocksExecutionAndReturnsResult_Test() { var operation = new TestOperation(); var startTime = DateTime.Now; var operationStatus = operation.RunSync(); var endTime = DateTime.Now; Assert.IsTrue(endTime - startTime >= TestOperation.OperationDuration); Assert.AreEqual(OperationState.CompletedSucessfully, operationStatus.Info.State); Assert.AreEqual(TestOperation.TEST_OPERATION_RESULT, operationStatus.Result); }
public void RunAsync_OnSuccessfulOperation_NotBlockExecutionAndReturnsOperationGuidAndOperationsManagerStatusContainsResult_Test() { var operationsManager = new OperationsManagerMock(); var operation = new TestOperation(operationsManager); var startTime = DateTime.Now; var enqueuedToken = operation.RunAsync(); var endTime = DateTime.Now; var beforeWaitOperationStatus = operationsManager.GetOperationStatus(enqueuedToken.OperationId); Thread.Sleep(TestOperation.OperationDuration + TestOperation.SafeTimeToSetOperationResult); var afterWaitOperationStatus = operationsManager.GetOperationStatus(enqueuedToken.OperationId); Assert.IsTrue(endTime - startTime < TestOperation.OperationDuration); Assert.AreEqual(OperationState.Started, beforeWaitOperationStatus.Info.State); Assert.IsNull(beforeWaitOperationStatus.Result); Assert.AreEqual(OperationState.CompletedSucessfully, afterWaitOperationStatus.Info.State); Assert.AreEqual(TestOperation.TEST_OPERATION_RESULT, afterWaitOperationStatus.Result); }
public void RunSync_OnFailureOperation_BlocksExecutionAndThrow_Test() { var operation = new TestOperation(isFailure: true); var startTime = DateTime.Now; Exception exception = null; try { operation.RunSync(); } catch(Exception ex) { exception = ex; } var endTime = DateTime.Now; Assert.IsTrue(endTime - startTime >= TestOperation.OperationDuration); Assert.IsNotNull(exception); Assert.AreEqual(TestOperation.OperationException, exception); }
public void Should_determine_two_dates_without_time_are_out_of_order() { var operation = new TestOperation { EarlierDate = new DateTime(2008, 4, 16), LaterDate = new DateTime(2008, 4, 15) }; ValidateDateComesBefore rule = CreateValidator(operation); string result = rule.IsValid(operation.EarlierDate); Assert.NotNull(result); }
private static ValidateDateComesBefore CreateValidator(TestOperation operation) { return new ValidateDateComesBefore { ToCompare = operation.LaterDate }; }
public void IsCancelationPending_OnNoOperationCancelationPendingInOperationManager_ReturnsFalse_Test() { var operation = new TestOperation(); operation.RunAsync(); var isCancelationPending = operation.IsCancelationPending(); Assert.AreEqual(false, isCancelationPending); }
public void TestWeightedSequentialExecution() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue<TestOperation> testQueueOperation = new OperationQueue<TestOperation>( new WeightedTransaction<TestOperation>[] { new WeightedTransaction<TestOperation>(operation1, 0.5f), new WeightedTransaction<TestOperation>(operation2, 2.0f) } ); IOperationQueueSubscriber mockedSubscriber = mockSubscriber(testQueueOperation); testQueueOperation.Start(); Expect.Once.On(mockedSubscriber). Method("ProgressChanged"). With( new Matcher[] { new NMock2.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)), new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.1f)) } ); operation1.ChangeProgress(0.5f); Expect.Once.On(mockedSubscriber). Method("ProgressChanged"). With( new Matcher[] { new NMock2.Matchers.TypeMatcher(typeof(OperationQueue<TestOperation>)), new ProgressUpdateEventArgsMatcher(new ProgressReportEventArgs(0.2f)) } ); operation1.SetEnded(); this.mockery.VerifyAllExpectationsHaveBeenMet(); }
public void IsCancelationPending_OnOperationCancelationPendingInOperationManager_ReturnsTrue_Test() { var operationsManager = new OperationsManagerMock(); var operation = new TestOperation(operationsManager); var enqueuedToken = operation.RunAsync(); operationsManager.SetOperationCancelFlag(enqueuedToken.OperationId); var isCancelationPending = operation.IsCancelationPending(); Assert.AreEqual(true, isCancelationPending); }
public void TestExceptionPropagation() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue<TestOperation> testQueueOperation = new OperationQueue<TestOperation>( new TestOperation[] { operation1, operation2 } ); testQueueOperation.Start(); Assert.IsFalse(testQueueOperation.Ended); operation1.SetEnded(); Assert.IsFalse(testQueueOperation.Ended); operation2.SetEnded(new AbortedException("Hello World")); Assert.Throws<AbortedException>( delegate() { testQueueOperation.Join(); } ); }
/// <summary> /// There are no comments for TestOperations in the schema. /// </summary> public void AddToTestOperations(TestOperation testOperation) { base.AddObject("TestOperations", testOperation); }
public void RunAsync_OnCanceledOperation_NotBlockExecutionAndReturnsOperationGuidAndOperationsManagerResultIsEmpty_Test() { var operationsManager = new OperationsManagerMock(); var operation = new TestOperation(operationsManager); var startTime = DateTime.Now; var enqueuedToken = operation.RunAsync(); var endTime = DateTime.Now; var beforeWaitOperationStatus = operationsManager.GetOperationStatus(enqueuedToken.OperationId); operation.ReportCancelationCompleted(); Thread.Sleep(TestOperation.OperationDuration + TestOperation.SafeTimeToSetOperationResult); var afterWaitOperationStatus = operationsManager.GetOperationStatus(enqueuedToken.OperationId); Assert.IsTrue(endTime - startTime < TestOperation.OperationDuration); Assert.AreEqual(OperationState.Started, beforeWaitOperationStatus.Info.State); Assert.IsNull(beforeWaitOperationStatus.Result); Assert.AreEqual(OperationState.Canceled, afterWaitOperationStatus.Info.State); Assert.IsNull(afterWaitOperationStatus.Result); }
/// <summary> /// Create a new TestOperation object. /// </summary> /// <param name="ID">Initial value of Id.</param> public static TestOperation CreateTestOperation(int ID) { TestOperation testOperation = new TestOperation(); testOperation.Id = ID; return testOperation; }
internal void SetOperation(TestOperation operation) { operation_ = operation; }
public void TestEndPropagation() { TestOperation operation1 = new TestOperation(); TestOperation operation2 = new TestOperation(); OperationQueue<TestOperation> testQueueOperation = new OperationQueue<TestOperation>( new TestOperation[] { operation1, operation2 } ); testQueueOperation.Start(); Assert.IsFalse(testQueueOperation.Ended); operation1.SetEnded(); Assert.IsFalse(testQueueOperation.Ended); operation2.SetEnded(); Assert.IsTrue(testQueueOperation.Ended); testQueueOperation.Join(); }
public void Should_not_return_error_if_both_dates_are_undefined() { var operation = new TestOperation { EarlierDate = null, LaterDate = null }; ValidateDateComesBefore rule = CreateValidator(operation); string result = rule.IsValid(operation.EarlierDate); Assert.Null(result); }
public void Should_not_return_error_if_later_date_is_undefined() { var operation = new TestOperation { EarlierDate = new DateTime(2008, 4, 15, 0, 0, 0), LaterDate = null }; ValidateDateComesBefore rule = CreateValidator(operation); string result = rule.IsValid(operation.EarlierDate); Assert.Null(result); }
public void Should_validate_that_two_dates_with_time_are_valid_when_they_are_equal() { var operation = new TestOperation { EarlierDate = new DateTime(2008, 4, 15, 9, 30, 0), LaterDate = new DateTime(2008, 4, 15, 9, 30, 0) }; ValidateDateComesBefore rule = CreateValidator(operation); string result = rule.IsValid(operation.EarlierDate); Assert.Null(result); }
public void ReportCancelationCompleted_OperationsManagerStatusIsCanceled_Test() { var operationsManager = new OperationsManagerMock(); var operation = new TestOperation(operationsManager); var enqueuedToken = operation.RunAsync(); operation.ReportCancelationCompleted(); var operationStatus = operationsManager.GetOperationStatus(enqueuedToken.OperationId); Assert.AreEqual(OperationState.Canceled, operationStatus.Info.State); }
public void ReportProgress_OperationsManagerStatusContainsReportedProgress_Test() { var operationsManager = new OperationsManagerMock(); var operation = new TestOperation(operationsManager); var enqueuedToken = operation.RunAsync(); operation.ReportProgress(TestOperation.OPERATION_PROGRESS); var operationStatus = operationsManager.GetOperationStatus(enqueuedToken.OperationId); Assert.AreEqual(TestOperation.OPERATION_PROGRESS, operationStatus.Info.Progress); }
public void InvokeTestOperation(TestOperation testOperation) { testOperation.Invoke(); testOperations.Add(testOperation); }
internal void SetOperation(TestOperation operation) { _operation = operation; }