Ejemplo n.º 1
0
        public void TryGetValueForMissingKey()
        {
            var key           = "hello";
            var expectedValue = 42;

            var dict = new Dictionary <string, object> {
                { "irrelevent", expectedValue }
            };

            var result = dict.MaybeGetValue(key);

            Assert.True(!result.IsSome);
        }
Ejemplo n.º 2
0
        public void TryGetValueForPresentKey()
        {
            var key           = "hello";
            var expectedValue = 42;

            var dict = new Dictionary <string, object> {
                { key, expectedValue }
            };

            var result = dict.MaybeGetValue(key);

            Assert.True(result.IsSome);
            Assert.Equal(expectedValue, result.ForceValue());
        }
Ejemplo n.º 3
0
        public void TryGetValueForMissingKey()
        {
            var key = "hello";
            var expectedValue = 42;

            var dict = new Dictionary<string, object> {{"irrelevent", expectedValue}};

            var result = dict.MaybeGetValue(key);
            
            Assert.That(!result.IsSome);
        }
Ejemplo n.º 4
0
        public void TryGetValueForPresentKey()
        {
            var key = "hello";
            var expectedValue = 42;

            var dict = new Dictionary<string, object> {{key, expectedValue}};

            var result = dict.MaybeGetValue(key);
            
            Assert.That(result.IsSome);
            Assert.That(result.ForceValue(), Is.EqualTo(expectedValue));
        }
Ejemplo n.º 5
0
 public virtual IMaybe <object> GetValue(IDependencyProperty dp)
 {
     return(store.MaybeGetValue(dp));
 }
Ejemplo n.º 6
0
 public Result <AnalogAdded> GenerateAnalogAddedFor(PointName pointName, PointCoordinate pointCoordinate) =>
 _analogPoints.MaybeGetValue(pointName).Unwrap(
     _ => Result.Fail <AnalogAdded>($"Analog point with name {pointName} already exists in remote."),
     () => new AnalogAdded(_remoteId, pointName, pointCoordinate).ToOkResult());