Beispiel #1
0
            public void StoresValueAndSpecInFuzzyContext()
            {
                var            value   = new TestClass();
                ConfiguredCall arrange = spec.Build().Returns(value);

                TestClass act = sut.Build(spec);

                Assert.Same(spec, FuzzyContext.Get <TestClass, Fuzzy <TestClass> >(value));
            }
Beispiel #2
0
        public void GetThrowsDescriptiveExceptionWhenValueDoesNotMatchPreviouslyStored()
        {
            FuzzyContext.Set(value, spec);

            var unexpected = new TestStruct(random.Next());
            var thrown     = Assert.Throws <ArgumentException>(() => FuzzyContext.Get <TestStruct, FuzzyRange <TestStruct> >(unexpected));

            Assert.Equal("value", thrown.ParamName);
            Assert.StartsWith($"{unexpected} is not a fuzzy value", thrown.Message);
        }
Beispiel #3
0
        public void SetStoresValuesSeparatelyForEachThread()
        {
            // Arrange
            TestStruct[] values              = Enumerable.Range(0, 16).Select(i => new TestStruct(random.Next())).ToArray();
            FuzzyRange <TestStruct>[] specs  = values.Select(v => CreateSpec()).ToArray();
            ParallelLoopResult        unused = Parallel.For(0, values.Length, i => {
                TestStruct value = values[i];
                FuzzyRange <TestStruct> expected = specs[i];

                // Act
                FuzzyContext.Set(value, expected);
                Thread.Sleep(1);
                FuzzyRange <TestStruct> actual = FuzzyContext.Get <TestStruct, FuzzyRange <TestStruct> >(value);

                // Assert
                Assert.Same(expected, actual);
            });
        }
Beispiel #4
0
 public void SetStoresValueForGet()
 {
     FuzzyContext.Set(value, spec);
     Assert.Same(spec, FuzzyContext.Get <TestStruct, FuzzyRange <TestStruct> >(value));
 }
Beispiel #5
0
        public void SetThrowsDescriptiveExceptionWhenSpecIsNull()
        {
            var thrown = Assert.Throws <ArgumentNullException>(() => FuzzyContext.Set(value, null !));

            Assert.Equal("spec", thrown.ParamName);
        }