예제 #1
0
        public void NextSequence()
        {
            var expected = TestValues.Select(x => (int)(x % int.MaxValue)).ToArray();
            var actual   = Enumerable.Range(0, TestValues.Length).Select(x => _rng.Next()).ToArray();

            Assert.Equal(expected, actual);
        }
예제 #2
0
        public void ServiceLayer_DeleteDomainTopic_DataLayerException_ShouldRethrow(bool getClientThrowsException, bool deleteThrowsException)
        {
            // Setup
            _eventGridManager.ThrowExceptionOnGetClient = getClientThrowsException;
            _eventGridManager.ThrowExceptionOnDelete    = deleteThrowsException;

            ServiceLayer serviceLayer = new ServiceLayer(
                _eventGridManager,
                _queueManager,
                _tableManager,
                _log);

            DataCleanupParameters parameters = TestValues.GetDataCleanupParameters();

            parameters.DomainTopicName = "domaintopicname";
            Func <Task> act = async() => await serviceLayer.DeleteDomainTopic(parameters);

            // Act
            act.Should().Throw <RequestFailedException>().WithMessage(_eventGridManager.ExceptionMessage);

            // Verify
            _log.Messages.Should().HaveCount(2);
            _log.Messages[0].Message.Should().Be($"Deleting domain topic {parameters.DomainTopicName}");
            _log.Messages[1].Message.Should().Be("Exception encountered in DeleteDomainTopic method.");
        }
예제 #3
0
        public void TestTryGetValueFalse()
        {
            TestValues values = new TestValues();

            Assert.IsFalse(Store.TryGetValue("name", out values._bool));
            Assert.IsFalse(Store.TryGetValue("name", out values._byte));
            Assert.IsFalse(Store.TryGetValue("name", out values._char));
            Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
            Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
            Assert.IsFalse(Store.TryGetValue("name", out values._double));
            Assert.IsFalse(Store.TryGetValue("name", out values._float));
            Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
            Assert.IsFalse(Store.TryGetValue("name", out values._int));
            Assert.IsFalse(Store.TryGetValue("name", out values._long));
            Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
            Assert.IsFalse(Store.TryGetValue("name", out values._short));
            Assert.IsFalse(Store.TryGetValue("name", out values._string));
            Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
            Assert.IsFalse(Store.TryGetValue("name", out values._uint));
            Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
            Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
            Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
            Assert.IsFalse(Store.TryGetValue("name", out values._Version));
            Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
        }
예제 #4
0
        private static PrimitiveMultiValueProperty GetPrimitiveMultiValueProperty(IRandomNumberGenerator random)
        {
            var val     = random.ChooseFrom(TestValues.CreatePrimitiveCollections(true, true));
            var payload = new PrimitiveMultiValueProperty("ArbitraryMultivalue", val);

            return(payload);
        }
예제 #5
0
        /// <summary>
        /// Generates an open entity set containing entities with different amounts of primitive open properties.
        /// </summary>
        /// <param name="model">The entity model. The method will modify the model and call Fixup().</param>
        /// <param name="withTypeNames">True if the payloads should specify type names.</param>
        /// <param name="primitiveValueFilter">A function for excluding primitives which are unsupported for open properties.</param>
        /// <returns>The open entity set containing entities with primitive open properties.</returns>
        public static ODataPayloadElement CreateOpenEntitySetInstance(EdmModel model, bool withTypeNames, Func <PrimitiveValue, bool> primitiveValueFilter)
        {
            ExceptionUtilities.CheckArgumentNotNull(model, "model");
            ExceptionUtilities.CheckArgumentNotNull(primitiveValueFilter, "primitiveValueFilter");

            var edmEntityType = new EdmEntityType("TestModel", "OpenEntityType", baseType: null, isAbstract: false, isOpen: true);

            model.AddElement(edmEntityType);
            edmEntityType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String, true);

            var container = new EdmEntityContainer("TestModel", "DefaultContainer");

            container.AddEntitySet("OpenEntityTypes", edmEntityType);
            model.AddElement(container);

            var feed = PayloadBuilder.EntitySet().WithTypeAnnotation(edmEntityType);

            string entityTypeName = withTypeNames ? edmEntityType.FullName() : null;

            var primitiveValues = TestValues.CreatePrimitiveValuesWithMetadata(true).Where(p => primitiveValueFilter(p));

            int idx = 0;

            for (int i = 0; i <= primitiveValues.Count(); ++i)
            {
                var entityInstance = PayloadBuilder.Entity(entityTypeName).PrimitiveProperty("Name", Guid.NewGuid().ToString());
                foreach (var property in primitiveValues.Take(i))
                {
                    entityInstance.PrimitiveProperty("Property" + (idx++), property.ClrValue);
                }
                feed.Add(entityInstance);
            }
            return(feed);
        }
예제 #6
0
        public void TestTryBadValues()
        {
            TestValues values = new TestValues();

            //fails all but string
            Store.SetValue("name", String.Empty);
            Assert.IsTrue(Store.TryGetValue("name", out values._string));
            Assert.AreEqual(String.Empty, values._string);

            Assert.IsFalse(Store.TryGetValue("name", out values._bool));
            Assert.IsFalse(Store.TryGetValue("name", out values._byte));
            Assert.IsFalse(Store.TryGetValue("name", out values._char));
            Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
            Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
            Assert.IsFalse(Store.TryGetValue("name", out values._double));
            Assert.IsFalse(Store.TryGetValue("name", out values._float));
            Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
            Assert.IsFalse(Store.TryGetValue("name", out values._int));
            Assert.IsFalse(Store.TryGetValue("name", out values._long));
            Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
            Assert.IsFalse(Store.TryGetValue("name", out values._short));
            Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
            Assert.IsFalse(Store.TryGetValue("name", out values._uint));
            Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
            Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
            Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
            Assert.IsFalse(Store.TryGetValue("name", out values._Version));
            Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TestValues testValues = db.TestValues.Find(id);

            db.TestValues.Remove(testValues);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #8
0
        public void NextBytes()
        {
            var expected = TestValues.Select(x => (byte)x).ToArray();

            var buffer = new byte[6];

            _rng.NextBytes(buffer);
            Assert.Equal(expected, buffer);
        }
예제 #9
0
        public void AccessValue_DefaultConstructed_Throws()
        {
            var arr = new Defined <TestValues> [1];

            Assert.Throws <InvalidOperationException>(() =>
            {
                TestValues a = arr[0];
            });
        }
예제 #10
0
        private static PrimitiveCollection GetPrimitiveCollection(IRandomNumberGenerator random)
        {
            TestValues.CreatePrimitiveValuesWithMetadata(true);
            PrimitiveValue val      = random.ChooseFrom(TestValues.CreatePrimitiveValuesWithMetadata(true));
            int            numItems = random.NextFromRange(1, 3);
            var            newItems = Enumerable.Range(0, numItems).Select(x => TestValues.GetDifferentPrimitiveValue(val));
            var            payload  = new PrimitiveCollection(newItems.ToArray());

            return(payload);
        }
예제 #11
0
        /// <summary>
        /// Creates a set of interesting stream reference (named stream) test descriptors, optionally with metadata.
        /// </summary>
        /// <param name="settings">The settings for payload reader test descriptor to use.</param>
        /// <param name="withMetadata">true if the generated test descriptors should have metadata.</param>
        /// <returns>Enumeration of interesting stream reference test descriptors.</returns>
        internal static IEnumerable <PayloadReaderTestDescriptor> CreateStreamReferenceValueTestDescriptors(PayloadReaderTestDescriptor.Settings settings, bool withMetadata)
        {
            EdmModel model = withMetadata ? new EdmModel().Fixup() : null;
            IEnumerable <NamedStreamInstance> namedStreams = TestValues.CreateStreamReferenceValues();

            return(namedStreams.Select(c => new PayloadReaderTestDescriptor(settings)
            {
                PayloadElement = c, PayloadEdmModel = model
            }));
        }
예제 #12
0
        public async Task <IActionResult> UpdateTaskValueById([FromBody] TestValues value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var testValue = await _context.TestValueses.FirstOrDefaultAsync(t => t.Id == value.Id);

            return(Ok(testValue));
        }
예제 #13
0
        public void DataCleanup_DomainTopicCleanup_NullOrWhitespaceDomainTopicName_ThrowsException(string topicName)
        {
            // Setup
            var    dataCleanup = new Functions(_ServiceLayer);
            string parameters  = TestValues.GetQueueMessageData(topicName);

            Func <Task> act = async() => await dataCleanup.DomainTopicCleanup(parameters);

            // Act + Verify
            act.Should().Throw <ArgumentException>().WithMessage("DomainTopicName value is invalid.");
        }
예제 #14
0
        public async Task DataCleanup_DomainTopicList_ShouldWork()
        {
            // Setup
            var dataCleanup = new Functions(_ServiceLayer);

            // Act
            await dataCleanup.DomainTopicList(TestValues.GetQueueMessageData());

            // Verify
            _ServiceLayer.PopulateDomainTopicQueueCalled.Should().BeTrue();
            _ServiceLayer.LastParametersPassed.Should().BeEquivalentTo(TestValues.GetDataCleanupParameters());
        }
예제 #15
0
        public async Task DataCleanup_DeleteTables_ShouldWork()
        {
            // Setup
            var dataCleanup = new Functions(_ServiceLayer);

            // Act
            var result = await dataCleanup.DeleteTables(TestValues.GetDataCleanupParameters());

            // Verify
            result.Should().BeOfType <OkResult>();
            _ServiceLayer.DeleteTablesCalled.Should().BeTrue();
        }
예제 #16
0
        /// <summary>
        /// Creates a set of interesting primitive value test descriptors along with metadata.
        /// </summary>
        /// <param name="settings">The settings for payload reader test descriptor to use.</param>
        /// <param name="fullSet">true if all available primitive values should be returned, false if only the most interesting subset should be returned.</param>
        /// <returns>List of interesting test descriptors.</returns>
        internal static IEnumerable <PayloadReaderTestDescriptor> CreatePrimitiveValueTestDescriptors(
            PayloadReaderTestDescriptor.Settings settings,
            bool fullSet = true)
        {
            EdmModel model = new EdmModel().Fixup();
            IEnumerable <PrimitiveValue> primitiveValues = TestValues.CreatePrimitiveValuesWithMetadata(fullSet);

            return(primitiveValues.Select(c => new PayloadReaderTestDescriptor(settings)
            {
                PayloadElement = c, PayloadEdmModel = model
            }));
        }
예제 #17
0
        /// <summary>
        /// Creates a set of interesting deferred navigation link test descriptors along with metadata.
        /// </summary>
        /// <param name="settings">The settings for payload reader test descriptor to use.</param>
        /// <param name="withMetadata">true if the generated test descriptors should have metadata.</param>
        /// <returns>Enumeration of interesting test descriptors.</returns>
        internal static IEnumerable <PayloadReaderTestDescriptor> CreateDeferredNavigationLinkTestDescriptors(
            PayloadReaderTestDescriptor.Settings settings,
            bool withMetadata)
        {
            EdmModel model = withMetadata ? new EdmModel().Fixup() : null;

            return(TestValues.CreateDeferredNavigationLinks().Select(navigationLink =>
                                                                     new PayloadReaderTestDescriptor(settings)
            {
                PayloadElement = navigationLink,
                PayloadEdmModel = model
            }));
        }
예제 #18
0
        /// <summary>
        /// Creates a set of interesting complex value test descriptors along with metadata.
        /// </summary>
        /// <param name="settings">The settings for payload reader test descriptor to use.</param>
        /// <param name="withTypeNames">true if the complex value payloads should specify type names.</param>
        /// <param name="withMetadata">true if the generated test descriptors should have metadata.</param>
        /// <param name="fullSet">true if all available complex values should be returned, false if only the most interesting subset should be returned.</param>
        /// <returns>List of interesting test descriptors.</returns>
        internal static IEnumerable <PayloadReaderTestDescriptor> CreateComplexValueTestDescriptors(
            PayloadReaderTestDescriptor.Settings settings,
            bool withTypeNames,
            bool fullSet = true)
        {
            EdmModel model = new EdmModel().Fixup();
            IEnumerable <ComplexInstance> complexValues = TestValues.CreateComplexValues(model, withTypeNames, fullSet);

            return(complexValues.Select(c => new PayloadReaderTestDescriptor(settings)
            {
                PayloadElement = c, PayloadEdmModel = model
            }));
        }
 public ActionResult Edit([Bind(Include = "TestNameID,TestDate,TestApproachID,TestValues01,TestValues02,TestValues03,TestValues04,TestValues05,ResultID,StyleID")] TestValues testValues)
 {
     if (ModelState.IsValid)
     {
         db.Entry(testValues).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.StyleID        = new SelectList(db.LogInitialStyle, "StyleID", "StyleID", testValues.StyleID);
     ViewBag.ResultID       = new SelectList(db.SetupResults, "ResultID", "ResultName", testValues.ResultID);
     ViewBag.TestApproachID = new SelectList(db.TestApproach, "TestApproachID", "TestName", testValues.TestApproachID);
     return(View(testValues));
 }
예제 #20
0
        private static PrimitiveMultiValue GenerateSimilarPrimitiveMultiValue(IRandomNumberGenerator random, PrimitiveMultiValue currentInstance)
        {
            PrimitiveMultiValue instance = ((PrimitiveMultiValue)currentInstance.DeepCopy());

            if (instance.Count != 0)
            {
                PrimitiveValue val      = instance.First();
                int            numItems = random.NextFromRange(1, 3);
                var            newItems = Enumerable.Range(0, numItems).Select(x => TestValues.GetDifferentPrimitiveValue(val));
                instance = new PrimitiveMultiValue(val.FullTypeName, false, newItems.ToArray());
            }

            return(instance);
        }
예제 #21
0
        public async Task DataCleanup_InitializeCleanup_ShouldWork()
        {
            // Setup
            var dataCleanup = new Functions(_ServiceLayer);

            // Act
            var result = await dataCleanup.InitializeCleanup(TestValues.GetDataCleanupParameters());

            // Verify
            result.Should().BeOfType <OkResult>();
            _ServiceLayer.DeleteQueuesCalled.Should().BeTrue();
            _ServiceLayer.DeleteTablesCalled.Should().BeTrue();
            _ServiceLayer.PopulateDomainTopicQueueCalled.Should().BeTrue();
        }
        // GET: TestValues/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestValues testValues = db.TestValues.Find(id);

            if (testValues == null)
            {
                return(HttpNotFound());
            }
            return(View(testValues));
        }
        private static void PopulatedDb(Context context)
        {
            ClearDb(context);

            context.Posts.Add(new Post {
                Id = 1, PublishDate = TestValues.DateInPast()
            });
            context.Posts.Add(new Post {
                Id = 2, PublishDate = TestValues.DateInPast()
            });
            context.Posts.Add(new Post {
                Id = 3, PublishDate = TestValues.DateInFuture()
            });
            context.SaveChanges();
        }
예제 #24
0
        /// <summary>
        /// Creates a set of interesting collections with complex items test descriptors along with metadata.
        /// </summary>
        /// <param name="withTypeNames">true if the complex value payloads should specify type names.</param>
        /// <param name="fullSet">true if all available complex collections should be returned, false if only the most interesting subset should be returned.</param>
        /// <returns>List of interesting test descriptors.</returns>
        internal static IEnumerable <PayloadReaderTestDescriptor> CreateComplexCollectionTestDescriptors(
            PayloadReaderTestDescriptor.Settings settings,
            bool withTypeNames,
            bool fullSet = true)
        {
            EdmModel model = new EdmModel().Fixup();
            IEnumerable <ComplexMultiValue> complexCollections = TestValues.CreateComplexCollections(model, withTypeNames, fullSet);

            return(complexCollections.Select(collection =>
                                             new PayloadReaderTestDescriptor(settings)
            {
                PayloadElement = collection,
                PayloadEdmModel = model,
                SkipTestConfiguration = tc => tc.Version < ODataVersion.V4,
            }));
        }
        public void ShouldLoadSettingsOnConstruct(bool condition)
        {
            // Arrange
            string text = TestValues.GetRandomString();

            _settingsAConfig.Settings.Condition = condition;
            _settingsAConfig.Settings.Text      = text;
            _settingsAConfig.SaveSettings();

            // Act
            _settingsAConfig = new ConfigurationManager <SettingsAStub>();

            // Assert
            Assert.That(_settingsAConfig.Settings.Condition, Is.EqualTo(condition));
            Assert.That(_settingsAConfig.Settings.Text, Is.EqualTo(text));
        }
        public void ShouldLoadSettingsWithoutInitializing(bool condition)
        {
            // Arrange
            var    appSettings = _settingsAConfig.Settings;
            string text        = TestValues.GetRandomString();

            appSettings.Condition = condition;
            appSettings.Text      = text;

            // Act
            _settingsAConfig.SaveSettings();
            var newAppSettings = ConfigurationManager <SettingsAStub> .LoadSettings(appSettings.GetFullPath());

            // Assert
            Assert.That(newAppSettings.Condition, Is.EqualTo(condition));
            Assert.That(newAppSettings.Text, Is.EqualTo(text));
        }
        // GET: TestValues/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestValues testValues = db.TestValues.Find(id);

            if (testValues == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StyleID        = new SelectList(db.LogInitialStyle, "StyleID", "StyleID", testValues.StyleID);
            ViewBag.ResultID       = new SelectList(db.SetupResults, "ResultID", "ResultName", testValues.ResultID);
            ViewBag.TestApproachID = new SelectList(db.TestApproach, "TestApproachID", "TestName", testValues.TestApproachID);
            return(View(testValues));
        }
예제 #28
0
        public async Task DataCleanup_DomainTopicCleanup_ShouldWork()
        {
            // Setup
            var    dataCleanup = new Functions(_ServiceLayer);
            string topicName   = "domaintopicname";
            string parameters  = TestValues.GetQueueMessageData(topicName);

            // Act
            await dataCleanup.DomainTopicCleanup(parameters);

            // Verify
            _ServiceLayer.DeleteDomainTopicCalled.Should().BeTrue();
            var expectedParameters = TestValues.GetDataCleanupParameters();

            expectedParameters.DomainTopicName = topicName;
            _ServiceLayer.LastParametersPassed.Should().BeEquivalentTo(expectedParameters);
        }
예제 #29
0
        public async Task SetterShouldBeInvoked()
        {
            var values = new TestValues();
            var option = new BooleanUserOption(() => "Test",
                                               () => Task.FromResult(values.Bool1),
                                               value =>
            {
                values.Bool1 = value;
                return(Task.FromResult(new SaveOptionResult()));
            },
                                               () => false);

            var settingValue = await option.GetSetting();

            Assert.IsTrue(settingValue);

            var rw = option.ReaderWriter;
        }
        public void ShouldSaveAndLoadSettingsCorrectly(bool condition)
        {
            // Arrange
            var    appSettings = _settingsAConfig.Settings;
            string text        = TestValues.GetRandomString();

            appSettings.Condition = condition;
            appSettings.Text      = text;

            // Act
            _settingsAConfig.SaveSettings();
            _settingsAConfig.LoadSettings();
            appSettings = _settingsAConfig.Settings;

            // Assert
            Assert.That(appSettings.Condition, Is.EqualTo(condition));
            Assert.That(appSettings.Text, Is.EqualTo(text));
        }
예제 #31
0
		public void TestTryGetValueFalse()
		{
			TestValues values = new TestValues();

			Assert.IsFalse(Store.TryGetValue("name", out values._bool));
			Assert.IsFalse(Store.TryGetValue("name", out values._byte));
			Assert.IsFalse(Store.TryGetValue("name", out values._char));
			Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
			Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
			Assert.IsFalse(Store.TryGetValue("name", out values._double));
			Assert.IsFalse(Store.TryGetValue("name", out values._float));
			Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
			Assert.IsFalse(Store.TryGetValue("name", out values._int));
			Assert.IsFalse(Store.TryGetValue("name", out values._long));
			Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
			Assert.IsFalse(Store.TryGetValue("name", out values._short));
			Assert.IsFalse(Store.TryGetValue("name", out values._string));
			Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
			Assert.IsFalse(Store.TryGetValue("name", out values._uint));
			Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
			Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
			Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
			Assert.IsFalse(Store.TryGetValue("name", out values._Version));
			Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
		}
예제 #32
0
		public void TestSetValue()
		{
			//Part 1, write
			Store.SetValue("bool", ValuesA._bool);
			Store.SetValue("byte", ValuesA._byte);
			Store.SetValue("char", ValuesA._char);
			Store.SetValue("DateTime", ValuesA._DateTime);
			Store.SetValue("decimal", ValuesA._decimal);
			Store.SetValue("double", ValuesA._double);
			Store.SetValue("float", ValuesA._float);
			Store.SetValue("Guid", ValuesA._Guid);
			Store.SetValue("int", ValuesA._int);
			Store.SetValue("long", ValuesA._long);
			Store.SetValue("sbyte", ValuesA._sbyte);
			Store.SetValue("short", ValuesA._short);
			Store.SetValue("string", ValuesA._string);
			Store.SetValue("TimeSpan", ValuesA._TimeSpan);
			Store.SetValue("uint", ValuesA._uint);
			Store.SetValue("ulong", ValuesA._ulong);
			Store.SetValue("Uri", ValuesA._Uri);
			Store.SetValue("ushort", ValuesA._ushort);
			Store.SetValue("Version", ValuesA._Version);
			Store.SetValue("object", ValuesA._object.GetType(), ValuesA._object);

			//Part 2, read
			TestValues values = new TestValues();

			Assert.IsTrue(Store.TryGetValue("bool", out values._bool));
			Assert.IsTrue(Store.TryGetValue("byte", out values._byte));
			Assert.IsTrue(Store.TryGetValue("char", out values._char));
			Assert.IsTrue(Store.TryGetValue("DateTime", out values._DateTime));
			Assert.IsTrue(Store.TryGetValue("decimal", out values._decimal));
			Assert.IsTrue(Store.TryGetValue("double", out values._double));
			Assert.IsTrue(Store.TryGetValue("float", out values._float));
			Assert.IsTrue(Store.TryGetValue("Guid", out values._Guid));
			Assert.IsTrue(Store.TryGetValue("int", out values._int));
			Assert.IsTrue(Store.TryGetValue("long", out values._long));
			Assert.IsTrue(Store.TryGetValue("sbyte", out values._sbyte));
			Assert.IsTrue(Store.TryGetValue("short", out values._short));
			Assert.IsTrue(Store.TryGetValue("string", out values._string));
			Assert.IsTrue(Store.TryGetValue("TimeSpan", out values._TimeSpan));
			Assert.IsTrue(Store.TryGetValue("uint", out values._uint));
			Assert.IsTrue(Store.TryGetValue("ulong", out values._ulong));
			Assert.IsTrue(Store.TryGetValue("Uri", out values._Uri));
			Assert.IsTrue(Store.TryGetValue("ushort", out values._ushort));
			Assert.IsTrue(Store.TryGetValue("Version", out values._Version));
			Assert.IsTrue(Store.TryGetValue("object", ValuesA._object.GetType(), out values._object));

			//Part 3, assert
			Assert.AreEqual(ValuesA._bool, values._bool);
			Assert.AreEqual(ValuesA._byte, values._byte);
			Assert.AreEqual(ValuesA._char, values._char);
			Assert.AreEqual(ValuesA._DateTime, values._DateTime);
			Assert.AreEqual(ValuesA._decimal, values._decimal);
			Assert.AreEqual(ValuesA._double, values._double);
			Assert.AreEqual(ValuesA._float, values._float);
			Assert.AreEqual(ValuesA._Guid, values._Guid);
			Assert.AreEqual(ValuesA._int, values._int);
			Assert.AreEqual(ValuesA._long, values._long);
			Assert.AreEqual(ValuesA._sbyte, values._sbyte);
			Assert.AreEqual(ValuesA._short, values._short);
			Assert.AreEqual(ValuesA._string, values._string);
			Assert.AreEqual(ValuesA._TimeSpan, values._TimeSpan);
			Assert.AreEqual(ValuesA._uint, values._uint);
			Assert.AreEqual(ValuesA._ulong, values._ulong);
			Assert.AreEqual(ValuesA._Uri, values._Uri);
			Assert.AreEqual(ValuesA._ushort, values._ushort);
			Assert.AreEqual(ValuesA._Version, values._Version);
			Assert.AreEqual(ValuesA._object, values._object);

			//Part 4, non-default GetValue
			Assert.AreEqual(ValuesA._bool, Store.GetValue("bool", ValuesB._bool));
			Assert.AreEqual(ValuesA._byte, Store.GetValue("byte", ValuesB._byte));
			Assert.AreEqual(ValuesA._char, Store.GetValue("char", ValuesB._char));
			Assert.AreEqual(ValuesA._DateTime, Store.GetValue("DateTime", ValuesB._DateTime));
			Assert.AreEqual(ValuesA._decimal, Store.GetValue("decimal", ValuesB._decimal));
			Assert.AreEqual(ValuesA._double, Store.GetValue("double", ValuesB._double));
			Assert.AreEqual(ValuesA._float, Store.GetValue("float", ValuesB._float));
			Assert.AreEqual(ValuesA._Guid, Store.GetValue("Guid", ValuesB._Guid));
			Assert.AreEqual(ValuesA._int, Store.GetValue("int", ValuesB._int));
			Assert.AreEqual(ValuesA._long, Store.GetValue("long", ValuesB._long));
			Assert.AreEqual(ValuesA._sbyte, Store.GetValue("sbyte", ValuesB._sbyte));
			Assert.AreEqual(ValuesA._short, Store.GetValue("short", ValuesB._short));
			Assert.AreEqual(ValuesA._string, Store.GetValue("string", ValuesB._string));
			Assert.AreEqual(ValuesA._TimeSpan, Store.GetValue("TimeSpan", ValuesB._TimeSpan));
			Assert.AreEqual(ValuesA._uint, Store.GetValue("uint", ValuesB._uint));
			Assert.AreEqual(ValuesA._ulong, Store.GetValue("ulong", ValuesB._ulong));
			Assert.AreEqual(ValuesA._Uri, Store.GetValue("Uri", ValuesB._Uri));
			Assert.AreEqual(ValuesA._ushort, Store.GetValue("ushort", ValuesB._ushort));
			Assert.AreEqual(ValuesA._Version, Store.GetValue("Version", ValuesB._Version));
			Assert.AreEqual(ValuesA._object, Store.GetValue("object", ValuesB._object.GetType(), ValuesB._object));
		}
예제 #33
0
		public void TestTryBadValues()
		{
			TestValues values = new TestValues();
			
			//fails all but string
			Store.SetValue("name", String.Empty);
			Assert.IsTrue(Store.TryGetValue("name", out values._string));
			Assert.AreEqual(String.Empty, values._string);

			Assert.IsFalse(Store.TryGetValue("name", out values._bool));
			Assert.IsFalse(Store.TryGetValue("name", out values._byte));
			Assert.IsFalse(Store.TryGetValue("name", out values._char));
			Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
			Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
			Assert.IsFalse(Store.TryGetValue("name", out values._double));
			Assert.IsFalse(Store.TryGetValue("name", out values._float));
			Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
			Assert.IsFalse(Store.TryGetValue("name", out values._int));
			Assert.IsFalse(Store.TryGetValue("name", out values._long));
			Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
			Assert.IsFalse(Store.TryGetValue("name", out values._short));
			Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
			Assert.IsFalse(Store.TryGetValue("name", out values._uint));
			Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
			Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
			Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
			Assert.IsFalse(Store.TryGetValue("name", out values._Version));
			Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
		}
		public void TestSerialize()
		{
			PropertySerializer ser = new PropertySerializer(typeof(TestValues1), ValueNames);
			ser.ContinueOnError = false;
			Assert.AreEqual(false, ser.ContinueOnError);

			ser.Serialize(ValuesA, Dictionary);

			TestValues test = new TestValues();
			ser.Deserialize(test, Dictionary);

			Assert.AreEqual(ValuesA._bool, test._bool);
			Assert.AreEqual(ValuesA._byte, test._byte);
			Assert.AreEqual(ValuesA._char, test._char);
			Assert.AreEqual(ValuesA._DateTime, test._DateTime);
			Assert.AreEqual(ValuesA._decimal, test._decimal);
			Assert.AreEqual(ValuesA._double, test._double);
			Assert.AreEqual(ValuesA._float, test._float);
			Assert.AreEqual(ValuesA._Guid, test._Guid);
			Assert.AreEqual(ValuesA._int, test._int);
			Assert.AreEqual(ValuesA._long, test._long);
			Assert.AreEqual(ValuesA._sbyte, test._sbyte);
			Assert.AreEqual(ValuesA._short, test._short);
			Assert.AreEqual(ValuesA._string, test._string);
			Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan);
			Assert.AreEqual(ValuesA._uint, test._uint);
			Assert.AreEqual(ValuesA._ulong, test._ulong);
			Assert.AreEqual(ValuesA._Uri, test._Uri);
			Assert.AreEqual(ValuesA._ushort, test._ushort);
			Assert.AreEqual(ValuesA._Version, test._Version);

			//ROK - note, it can not deserialize this since it does not know the type:
			Assert.AreEqual(null, test._object);
		}