private static IOperation <IPersistedObjectSpace> ManOrBoyCore(IAssertOperationFactory assert) => PersistedObjectSpaceOperation.CreateValue <int>("bar").Bind(value => Operation.Sequence( // // Check the identifier // assert.AreEqual( value.GetId(), "bar" ), // // Initialized with default value // assert.AreEqual( value.Get(), 0 ), // // Perform assignment // value.Set(42), // // Check value after assignment // assert.AreEqual( value.Get(), 42 ) ) );
private static IOperation <IPersistedObjectSpace> CreateAndGetCore(IAssertOperationFactory assert) => Operation.Sequence( // // Exceptions thrown by Create. // Operation.Sequence( assert.ThrowsException <ArgumentNullException>().When(PersistedObjectSpaceOperation.CreateQueue <int>(null)) ), // // Exceptions thrown by Get. // Operation.Sequence( assert.ThrowsException <ArgumentNullException>().When(PersistedObjectSpaceOperation.GetQueue <int>(null)), assert.ThrowsException <KeyNotFoundException>().When(PersistedObjectSpaceOperation.GetQueue <int>("bar")) ), // // Exceptions thrown by Delete. // Operation.Sequence( assert.ThrowsException <KeyNotFoundException>().When(PersistedObjectSpaceOperation.Delete("bar")) ), // // Create a new queue. // PersistedObjectSpaceOperation.CreateQueue <int>("bar").Apply(queue => // // Check the new queue is present in the object space. // Operation.Sequence( // // Assert we can get the same instance back using GetQueue. // assert.AreSame( PersistedObjectSpaceOperation.GetQueue <int>("bar"), queue ), // // Assert we can't create an artifact with the same name. // Operation.Sequence( assert.ThrowsException <InvalidOperationException>().When(PersistedObjectSpaceOperation.CreateArray <int>("bar", 42)), assert.ThrowsException <InvalidOperationException>().When(PersistedObjectSpaceOperation.CreateDictionary <int, int>("bar")), assert.ThrowsException <InvalidOperationException>().When(PersistedObjectSpaceOperation.CreateList <int>("bar")), assert.ThrowsException <InvalidOperationException>().When(PersistedObjectSpaceOperation.CreateQueue <int>("bar")), assert.ThrowsException <InvalidOperationException>().When(PersistedObjectSpaceOperation.CreateSet <int>("bar")), assert.ThrowsException <InvalidOperationException>().When(PersistedObjectSpaceOperation.CreateStack <int>("bar")), assert.ThrowsException <InvalidOperationException>().When(PersistedObjectSpaceOperation.CreateValue <int>("bar")) ) ) ), // // Delete queue. // PersistedObjectSpaceOperation.Delete("bar"), // // Check the queue is no longer present in the object space. // Operation.Sequence( assert.ThrowsException <KeyNotFoundException>().When(PersistedObjectSpaceOperation.GetQueue <int>("bar")), assert.ThrowsException <KeyNotFoundException>().When(PersistedObjectSpaceOperation.Delete("bar")) ) );