public void Store_WithStateStateWithOptions_OptionsShouldEqualInput() { FileStateStore store = GetStateStore(); var testState = new StorableMaintenanceState(); StorableOption testOption = new StorableOption { StringValue = "test", TypeName = "testType" }; testState.MiddlewareOptions = new List <StorableOption> { testOption }; store.SetState(testState); store.GetState().MiddlewareOptions .ShouldNotBeNull() .ShouldNotBeEmpty(); StorableOption firstOption = store.GetState() .MiddlewareOptions.First(); firstOption.StringValue .ShouldBe(testOption.StringValue); firstOption.TypeName .ShouldBe(testOption.TypeName); }
private ISerializableOption RestoreOption(StorableOption storableOpt) { Type optionType = _optionTypes.Single(t => t.Name == storableOpt.TypeName); ISerializableOption option = (ISerializableOption)Activator.CreateInstance(optionType); option.LoadFromString(storableOpt.StringValue); return(option); }