public void Save(InstanceModel instance)
        {
            if (!ActiveRecordStarter.IsInitialized)
                ActiveRecordStarter.Initialize();

            instance.Save();
        }
 public void Save(InstanceModel instance)
 {
     //throw new NotImplementedException();
     _instances.Add(instance);
     InstanceModel found = _instances.Find(x => x.InstanceName == instance.InstanceName);
     if (found != null)
     {
         _instances.Remove(found);
     }
     _instances.Add(instance);
 }
        public InstanceModel GetInstance(string instanceName)
        {
            if (!ActiveRecordStarter.IsInitialized)
                ActiveRecordStarter.Initialize();

            InstanceModel instance = new InstanceModel();

            instance = InstanceModel.FindFirst(Expression.Eq("InstanceName", instanceName));

            return instance;
        }
        public InstanceModel GetInstanceByID(int instanceID)
        {
            if (!ActiveRecordStarter.IsInitialized)
                ActiveRecordStarter.Initialize();

            InstanceModel instance = new InstanceModel();

            instance = InstanceModel.Find(instanceID);
            
            return instance;
        }
Esempio n. 5
0
        public ActionResult Instance(string node)
        {
            var i = SQLInstance.Get(node);

            var vd = new InstanceModel
            {
                View            = SQLViews.Instance,
                Refresh         = node.HasValue() ? 10 : 5,
                CurrentInstance = i
            };

            return(View("Instance", vd));
        }
Esempio n. 6
0
        private IEnumerable <MagicColor> GetColors(InstanceModel model)
        {
            if (model.Colors != null)
            {
                return(GetColorFromColorArray(model.Colors));
            }

            if (model.CardTypes != null && model.CardTypes.Contains("CardType_Land"))
            {
                return(GetColorsForLand(model));
            }

            return(Enumerable.Empty <MagicColor>());
        }
Esempio n. 7
0
 public EmergingPattern ExtractPattern(List <SelectorContext> currentContext, InstanceModel model,
                                       Feature classFeature, IChildSelector selector, int index)
 {
     return
         (Create(
              currentContext.Union(new List <SelectorContext>
     {
         new SelectorContext
         {
             Selector = selector,
             Index = index
         }
     }), model, classFeature));
 }
Esempio n. 8
0
        public void UpdateSettings(InstanceModel model)
        {
            var settings = this.Platform <ISettings>();
            var index    = Instances.FindIndex(it => it.CreateAt == model.CreateAt);

            if (index > 0)
            {
                Instances[index] = model;
            }

            settings.Set("instance", Instances);
            RockApp.Current.GetAllInstance();
            OnPropertyChanged(nameof(Instances));
        }
Esempio n. 9
0
        public bool InsertInstance(InstanceModel im)
        {
            //Mappers
            InstanceEntity ie = new InstanceEntity();

            ie.Id          = im.Id;
            ie.Name        = im.Name;
            ie.Type        = im.Type;
            ie.Location    = im.Location;
            ie.Media       = im.Media;
            ie.Description = im.Description;

            return(_instanceRepo.Insert(ie));
        }
Esempio n. 10
0
        public async Task Login(InstanceModel instance)
        {
            if (instance.Client != null)
            {
                throw new RocketClientException("Already Login");
            }

            Host  = instance.Host;
            Proxy = instance.ProxySettings?.ToWebProxy();
            await CheckServer();

            var result = await _currentClient.Login(instance.Token);

            instance.Client = _currentClient;
        }
Esempio n. 11
0
        private IEnumerable <MagicColor> GetColorsForLand(InstanceModel model)
        {
            if (model.CardSubtypes == null)
            {
                yield break;
            }

            foreach (var subType in model.CardSubtypes)
            {
                if (landColorMap.TryGetValue(subType, out var color))
                {
                    yield return(color);
                }
            }
        }
Esempio n. 12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void terminate() throws org.maltparser.core.exception.MaltChainedException
        public virtual void terminate()
        {
            if (instanceModel != null)
            {
                instanceModel.terminate();
                instanceModel = null;
            }
            if (children != null)
            {
                foreach (DecisionModel child in children.Values)
                {
                    child.terminate();
                }
            }
        }
Esempio n. 13
0
        public async Task <PagedOctopusModel <EventOctopusModel> > GetAllEvents(InstanceModel instanceModel, SyncModel syncModel, int startIndex)
        {
            var client  = new RestClient(instanceModel.Url);
            var request = new RestRequest($"api/events");

            request.AddQueryParameter("from", syncModel.SearchStartDate.GetValueOrDefault().ToString("O"));
            request.AddQueryParameter("to", syncModel.Started.GetValueOrDefault().ToString("O"));
            request.AddQueryParameter("eventCategories", OctopusEventCategories.DeploymentStarted);
            request.AddQueryParameter("skip", startIndex.ToString());
            request.AddQueryParameter("take", "10");
            request.AddHeader("X-Octopus-ApiKey", instanceModel.ApiKey);

            var response = await client.ExecuteGetAsync(request);

            return(JsonConvert.DeserializeObject <PagedOctopusModel <EventOctopusModel> >(response.Content));
        }
        private void DownloadPlacename()
        {
            this.AppendLineMessages("Download Placename.");

            var model = new InstanceModel();

            // XIVDB からInstanceのリストを取得する
            model.GET(this.viewModel.Language);

            // 取得したリストをCSVに保存する
            model.SaveToCSV(
                Path.Combine(this.viewModel.SaveDirectory, $"Placename.{this.viewModel.Language.ToText()}.csv"),
                this.viewModel.Language);

            this.AppendLineMessages("Download Placename, Done.");
        }
Esempio n. 15
0
        public async Task <ReleaseModel> GetSpecificRelease(InstanceModel instanceModel, SpaceModel space, ProjectModel project, string releaseId)
        {
            var client  = new RestClient(instanceModel.Url);
            var request = new RestRequest($"api/{space.OctopusId}/release/{releaseId}");

            request.AddHeader("X-Octopus-ApiKey", instanceModel.ApiKey);

            var response = await client.ExecuteGetAsync(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var octopusRelease = JsonConvert.DeserializeObject <ReleaseOctopusModel>(response.Content);
                return(_modelConverter.ConvertFromOctopusToReleaseModel(octopusRelease, project.Id));
            }

            return(null);
        }
Esempio n. 16
0
        public InstanceModel GetOneInstance(int id)
        {
            InstanceEntity instanceEntity = _instanceRepo.GetOne(id);

            InstanceModel im = new InstanceModel();

            im.Id          = instanceEntity.Id;
            im.Name        = instanceEntity.Name;
            im.Type        = instanceEntity.Type;
            im.Media       = instanceEntity.Media;
            im.Description = instanceEntity.Description;
            im.Location    = instanceEntity.Location;



            return(im);
        }
Esempio n. 17
0
        public List <InstanceModel> GetAllInstances()
        {
            List <InstanceModel>  instModels       = new List <InstanceModel>();
            List <InstanceEntity> instanceEntities = _instanceRepo.Get();

            foreach (InstanceEntity instanceEntity in instanceEntities)
            {
                InstanceModel im = new InstanceModel();
                im.Id    = instanceEntity.Id;
                im.Name  = instanceEntity.Name;
                im.Type  = instanceEntity.Type;
                im.Media = instanceEntity.Media;
                instModels.Add(im);
            }

            return(instModels);
        }
Esempio n. 18
0
        public IEnumerable <IEmergingPattern> Mine(InstanceModel model, IEnumerable <Instance> instances, Feature classFeature)
        {
            EmergingPatternCreator                EpCreator  = new EmergingPatternCreator();
            EmergingPatternComparer               epComparer = new EmergingPatternComparer(new ItemComparer());
            IEmergingPatternSimplifier            simplifier = new EmergingPatternSimplifier(new ItemComparer());
            FilteredCollection <IEmergingPattern> minimal    =
                new FilteredCollection <IEmergingPattern>(epComparer.Compare, FilterRelation);

            if (MinePatternsWhileBuildingTree)
            {
                DecisionTreeBuilder.OnSplitEvaluation =
                    delegate(IDecisionTreeNode node, ISplitIterator iterator, List <SelectorContext> currentContext)
                {
                    IChildSelector currentSelector = null;
                    for (int i = 0; i < iterator.CurrentDistribution.Length; i++)
                    {
                        double[] distribution = iterator.CurrentDistribution[i];
                        if (EPTester.Test(distribution, model, classFeature))
                        {
                            if (currentSelector == null)
                            {
                                currentSelector = iterator.CreateCurrentChildSelector();
                            }
                            EmergingPattern ep = EpCreator.ExtractPattern(currentContext, model, classFeature,
                                                                          currentSelector, i);
                            ep.Counts = (double[])distribution.Clone();
                            minimal.Add(simplifier.Simplify(ep));
                        }
                    }
                };
                DoMine(model, instances, classFeature, EpCreator, null);
            }
            else
            {
                DoMine(model, instances, classFeature, EpCreator, p =>
                {
                    if (EPTester.Test(p.Counts, model, classFeature))
                    {
                        minimal.Add(simplifier.Simplify(p));
                    }
                }
                       );
            }
            return(minimal.GetItems());
        }
Esempio n. 19
0
        public async Task <IActionResult> Save(InstanceModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View("InstanceMaintenance", model));
            }

            if (model.Id > 0)
            {
                await _instanceRepository.UpdateAsync(model);
            }
            else
            {
                await _instanceRepository.InsertAsync(model);
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 20
0
        public EmergingPattern Create(IEnumerable <SelectorContext> contexes, InstanceModel model, Feature classFeature)
        {
            EmergingPattern result = new EmergingPattern(model, classFeature, 0);

            foreach (SelectorContext context in contexes)
            {
                IChildSelector childSelector = context.Selector;
                ItemBuilder    builder;
                if (!builderForType.TryGetValue(childSelector.GetType(), out builder))
                {
                    throw new InvalidOperationException(string.Format("Unknown selector: '{0}'", childSelector.GetType().Name));
                }
                Item item = builder.GetItem(childSelector, context.Index);
                item.Model = model;
                result.Items.Add(item);
            }
            return(result);
        }
Esempio n. 21
0
        public async Task <InstanceModel> Login(string credentialToken, string credentialSecret)
        {
            if (string.IsNullOrEmpty(credentialToken) || string.IsNullOrEmpty(credentialSecret))
            {
                throw new ArgumentNullException($"{nameof(credentialToken)} and {nameof(credentialSecret)} can not be null or empty");
            }

            var result = await _currentClient.OAuthLogin(credentialToken, credentialSecret);

            var userInfo = await _currentClient.GetUserInfo(result.Id);

            if (string.IsNullOrEmpty(userInfo.UserName))
            {
                var usernameSuggestion = await _currentClient.GetUsernameSuggestion();

                var name = await this.Platform <IDialog>().ShowInput(new InputDialogData
                {
                    InputDefaultValue = usernameSuggestion,
                    Title             = "Register UserName",
                    Content           = "The username is used to allow others to mention you in messages."
                });

                if (string.IsNullOrEmpty(name))
                {
                    throw new TaskCanceledException();
                }

                await _currentClient.SetUsername(name);
            }

            var model = new InstanceModel
            {
                CreateAt = DateTime.UtcNow,
                Client   = _currentClient,
                Expires  = result.TokenExpires.ToDateTime(),
                Host     = Host,
                ImType   = IMType.RocketChat,
                Token    = result.Token,
                UserId   = result.Id
            };

            RockApp.Current.AddInstance(model);
            return(model);
        }
Esempio n. 22
0
        public int AddInstance(InstanceModel model, string name)
        {
            var entity = new PKS_KCASE_INSTANCE
            {
                NAME            = model.Name,
                BODESCRIPTION   = model.BoDescription,
                REMARK          = model.Remark,
                AUTHOR          = model.Author,
                AUDITOR         = model.Auditor,
                KCASETHEMEID    = model.KCaseThemeId,
                CREATEDBY       = name,
                CREATEDDATE     = DateTime.Now,
                LASTUPDATEDBY   = name,
                LASTUPDATEDDATE = DateTime.Now
            };

            _kCaseInstanceRepository.Add(entity);
            return(entity.Id);
        }
Esempio n. 23
0
        public ISplitIterator GetSplitIterator(InstanceModel model, Feature feature, Feature classFeature)
        {
            if (iterators == null)
            {
                InitializeIterators();
            }
            ISplitIterator result;

            if (iterators.TryGetValue(feature.GetType(), out result))
            {
                result.Model        = model;
                result.ClassFeature = classFeature;
                return(result);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 24
0
        public int UpdateInstance(InstanceModel model, string name)
        {
            var entity = _kCaseInstanceRepository.GetQuery()
                         .FirstOrDefault(t => t.Id == model.Id);

            if (entity == null)
            {
                return(-1);
            }
            entity.NAME            = model.Name;
            entity.BODESCRIPTION   = model.BoDescription;
            entity.REMARK          = model.Remark;
            entity.AUTHOR          = model.Author;
            entity.AUDITOR         = model.Auditor;
            entity.LASTUPDATEDBY   = name;
            entity.LASTUPDATEDDATE = DateTime.Now;
            _kCaseInstanceRepository.Update(entity);
            return(entity.Id);
        }
Esempio n. 25
0
        public void Valid_name_and_connection_information()
        {
            //Arrange
            //Models.InstanceRepository repo = new QuartzAdmin.web.Models.InstanceRepository();
            FormCollection formData = new FormCollection();

            QuartzAdmin.web.Controllers.InstanceController controller = GetInstanceController();
            formData.Add("InstanceName", "MyFirstInstance");
            formData.Add("InstancePropertyKey1", "Red");
            formData.Add("InstancyPropertyValue1", "Dog");
            controller.ValueProvider = formData.ToValueProvider();

            //Act
            controller.Create(formData);
            InstanceModel newInstance = controller.Repository.GetByName("MyFirstInstance");

            //Assert
            Assert.IsNotNull(newInstance);
            Assert.AreEqual(formData["InstanceName"], newInstance.InstanceName);
        }
Esempio n. 26
0
        public string ToString(int ident, InstanceModel model, int digits = -1)
        {
            // "-[2,3]\n -IntFeature<=4 [1,1]\n -IntFeature>4 [1,2]"
            StringBuilder builder = new StringBuilder();

            builder.Append(Data.ToStringEx(digits));
            if (!IsLeaf)
            {
                for (int i = 0; i < Children.Length; i++)
                {
                    IDecisionTreeNode child = Children[i];
                    builder.Append("\n");
                    builder.Append(' ', (ident + 1) * 3);
                    builder.Append("- ");
                    builder.Append(ChildSelector.ToString(model, i));
                    builder.Append(' ');
                    builder.Append(child.ToString(ident + 1, model));
                }
            }
            return(builder.ToString());
        }
Esempio n. 27
0
        void Receive_RequestInstance(XConnection connection, GenericPacket request)
        {
            // received by server from client

            SyncClient client;

            if (!SyncClients.TryGetValue(connection.GetHashCode(), out client))
            {
                Log("Request Instance: Sync client not found");
                return;
            }

            var threadID = int.Parse(request.Data["ThreadID"]);

            var node = XRay.Nodes[int.Parse(request.Data["NodeID"])];

            string filter = null;

            request.Data.TryGetValue("Filter", out filter);

            var model = new InstanceModel(node, filter);

            client.SelectedInstances[threadID] = model;
            Log("Request Instance: Model added for thread " + threadID.ToString());

            model.BeginUpdateTree(false);

            // send back details, columns, and nodes
            var response = new InstancePacket()
            {
                Type     = InstancePacketType.Root,
                ThreadID = threadID,
                Details  = model.DetailsLabel,
                Columns  = model.Columns,
                Fields   = model.RootNodes
            };

            client.Connection.SendPacket(response);
        }
Esempio n. 28
0
        public InstanceModel GetInstance(int id)
        {
            var query = _kCaseInstanceRepository.GetQuery()
                        .FirstOrDefault(t => t.Id == id);

            if (query == null)
            {
                return(null);
            }
            InstanceModel result = new InstanceModel
            {
                Id            = query.Id,
                Name          = query.NAME,
                BoDescription = query.BODESCRIPTION,
                Remark        = query.REMARK,
                Author        = query.AUTHOR,
                Auditor       = query.AUDITOR,
                KCaseThemeId  = query.KCASETHEMEID
            };

            return(result);
        }
Esempio n. 29
0
        public async Task <InstanceModel> GetInstanceById(string instanceId)
        {
            var apiUrl  = string.Format("/instances/{0}", instanceId);
            var request = new RestRequest(apiUrl, Method.GET);

            var response = await this.SendRequestAsync <InstanceModel>(request, string.Empty, apiUrl);

            if (response.IsSuccessful)
            {
                var preview = _appSettings.OrthancServiceUrl + "/instances/" + response.Data.ID + "/preview";
                var file    = _appSettings.OrthancServiceUrl + "/instances/" + response.Data.ID + "/file";

                response.Data.File    = file;
                response.Data.Preview = preview;

                return(response.Data);
            }

            InstanceModel returnResponse = new InstanceModel();

            return(await Task.FromResult <InstanceModel>(returnResponse));
        }
Esempio n. 30
0
        private InstanceModel GetTestInstance()
        {
            InstanceModel instance = new InstanceModel();

            instance.InstanceName = "MyTestInstance";
            instance.InstanceProperties.Add(new InstancePropertyModel()
            {
                PropertyName = "quartz.scheduler.instanceName", PropertyValue = "SampleQuartzScheduler"
            });
            instance.InstanceProperties.Add(new InstancePropertyModel()
            {
                PropertyName = "quartz.threadPool.type", PropertyValue = "Quartz.Simpl.SimpleThreadPool, Quartz"
            });
            instance.InstanceProperties.Add(new InstancePropertyModel()
            {
                PropertyName = "quartz.scheduler.proxy", PropertyValue = "true"
            });
            instance.InstanceProperties.Add(new InstancePropertyModel()
            {
                PropertyName = "quartz.scheduler.proxy.address", PropertyValue = "tcp://localhost:567/QuartzScheduler"
            });
            return(instance);
        }
Esempio n. 31
0
        public void List_all_triggers_in_an_instance()
        {
            // Arrange
            InstanceController controller = GetInstanceController();
            InstanceModel      instance   = GetTestInstance();

            controller.Repository.Save(instance);

            // Act
            ActionResult result          = controller.Connect(instance.InstanceName);
            int          countOfTriggers = 0;

            if (result is ViewResult)
            {
                if (((ViewResult)result).ViewData.Model is InstanceViewModel)
                {
                    countOfTriggers = ((InstanceViewModel)((ViewResult)result).ViewData.Model).Triggers.Count;
                }
            }

            // Assert
            Assert.IsTrue(countOfTriggers > 0);
        }
Esempio n. 32
0
        public void Verify_quartz_is_running()
        {
            // Arrange
            InstanceController controller = GetInstanceController();
            InstanceModel      instance   = GetTestInstance();

            controller.Repository.Save(instance);

            // Act
            ActionResult result      = controller.Connect(instance.InstanceName);
            bool         isConnected = false;

            if (result is ViewResult)
            {
                if (((ViewResult)result).ViewData.Model is InstanceViewModel)
                {
                    isConnected = true;
                }
            }

            // Assert
            Assert.IsTrue(isConnected);
        }
Esempio n. 33
0
        /// <summary>
        /// Constructs a Lib learner.
        /// </summary>
        /// <param name="owner"> the guide model owner </param>
        /// <param name="learnerMode"> the mode of the learner BATCH or CLASSIFY </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Lib(org.maltparser.parser.guide.instance.InstanceModel owner, System.Nullable<int> learnerMode, String learningMethodName) throws org.maltparser.core.exception.MaltChainedException
        public Lib(InstanceModel owner, int?learnerMode, string learningMethodName)
        {
            this.owner       = owner;
            this.learnerMode = learnerMode.Value;
            name             = learningMethodName;
            if (Configuration.getOptionValue("lib", "verbosity") != null)
            {
                verbosity = Enum.Parse(typeof(Verbostity), Configuration.getOptionValue("lib", "verbosity").ToString().ToUpper());
            }
            else
            {
                verbosity = Verbostity.SILENT;
            }
            NumberOfInstances = 0;
            if (Configuration.getOptionValue("singlemalt", "null_value") != null && Configuration.getOptionValue("singlemalt", "null_value").ToString().Equals("none", StringComparison.OrdinalIgnoreCase))
            {
                excludeNullValues = true;
            }
            else
            {
                excludeNullValues = false;
            }

            if (learnerMode.Value == LearningMethod_Fields.BATCH)
            {
                featureMap     = new FeatureMap();
                instanceOutput = new StreamWriter(getInstanceOutputStreamWriter(".ins"));
            }
            else if (learnerMode.Value == LearningMethod_Fields.CLASSIFY)
            {
                featureMap = (FeatureMap)getConfigFileEntryObject(".map");
            }
            else
            {
                featureMap = null;
            }
        }
Esempio n. 34
0
        public async Task <List <DeploymentModel> > GetAllDeploymentsForReleaseAsync(InstanceModel instanceModel, SpaceModel space, ProjectModel project, ReleaseModel release, Dictionary <string, EnvironmentModel> environmentDictionary, Dictionary <string, TenantModel> tenantDictionary)
        {
            var startIndex    = -10;
            var returnList    = new List <DeploymentModel>();
            var continueQuery = true;
            var client        = new RestClient(instanceModel.Url);

            while (continueQuery)
            {
                startIndex += 10;
                var request = new RestRequest($"api/{space.OctopusId}/releases/{release.OctopusId}/deployments");
                request.AddQueryParameter("skip", startIndex.ToString());
                request.AddQueryParameter("task", "10");
                request.AddHeader("X-Octopus-ApiKey", instanceModel.ApiKey);

                var response = await client.ExecuteGetAsync(request);

                var pagedModel = JsonConvert.DeserializeObject <PagedOctopusModel <DeploymentOctopusModel> >(response.Content);

                foreach (var item in pagedModel.Items)
                {
                    var deploymentRequest = new RestRequest(item.Links.Task);
                    deploymentRequest.AddHeader("X-Octopus-ApiKey", instanceModel.ApiKey);

                    var deploymentResponse = await client.ExecuteGetAsync(deploymentRequest);

                    var deploymentTaskModel = JsonConvert.DeserializeObject <DeploymentOctopusTaskModel>(deploymentResponse.Content);

                    returnList.Add(_modelConverter.ConvertFromOctopusToDeploymentModel(item, deploymentTaskModel, release.Id, environmentDictionary, tenantDictionary));
                }

                continueQuery = returnList.Count < pagedModel.TotalResults && pagedModel.Items.Count > 0;
            }

            return(returnList);
        }
Esempio n. 35
0
		private void modelLoaded(object sender, bool succeeded)
		{
			if (succeeded) instanceModel = new InstanceModel((Model)sender);
		}
 public JobRepository(InstanceModel instance)
 {
     quartzInstance = instance;
 }
 public JobRepository(string instanceName)
 {
     InstanceRepository repo = new InstanceRepository();
     quartzInstance = repo.GetInstance(instanceName);
 }
 public CalendarRepository(Models.InstanceModel instance)
 {
     quartzInstance = instance;
 }
Esempio n. 39
0
 private InstanceModel GetTestInstance()
 {
     InstanceModel instance = new InstanceModel();
     instance.InstanceName = "MyTestInstance";
     instance.InstanceProperties.Add(new InstancePropertyModel() { PropertyName = "quartz.scheduler.instanceName", PropertyValue = "SampleQuartzScheduler" });
     instance.InstanceProperties.Add(new InstancePropertyModel() { PropertyName = "quartz.threadPool.type", PropertyValue = "Quartz.Simpl.SimpleThreadPool, Quartz" });
     instance.InstanceProperties.Add(new InstancePropertyModel() { PropertyName = "quartz.scheduler.proxy", PropertyValue = "true" });
     instance.InstanceProperties.Add(new InstancePropertyModel() { PropertyName = "quartz.scheduler.proxy.address", PropertyValue = "tcp://localhost:567/QuartzScheduler" });
     return instance;
 }
 public TriggerRepository(InstanceModel instance)
 {
     quartzInstance = instance;
 }
 public void Delete(InstanceModel instance)
 {
     _instances.Remove(instance);
 }
Esempio n. 42
0
        public void Can_Save_Valid_Instance()
        {
            // Организация - создание имитированного хранилища данных
            Mock<IInstanceRepository> mock = new Mock<IInstanceRepository>();

            // Организация - создание контроллера
            InstanceController controller = CreateInstanceController(mock.Object, null, null, null);

            //Организация - создание объекта Варианта
            InstanceModel instance = new InstanceModel();

            // Действие - попытка сохранения Варианта
            ActionResult result = controller.Edit(instance,null);

            // Утверждение - проверка того, что к хранилищу производится обращение
            mock.Verify(m => m.Save(instance));

            // Утверждение - проверка типа результата метода
            Assert.IsNotInstanceOfType(result, typeof(ViewResult));

        }
Esempio n. 43
0
        void Receive_RequestInstance(XConnection connection, GenericPacket request)
        {
            // received by server from client

            SyncClient client;
            if (!SyncClients.TryGetValue(connection.GetHashCode(), out client))
            {
                Log("Request Instance: Sync client not found");
                return;
            }

            var threadID = int.Parse(request.Data["ThreadID"]);

            var node = XRay.Nodes[int.Parse(request.Data["NodeID"])];

            string filter = null;
            request.Data.TryGetValue("Filter", out filter);

            var model = new InstanceModel(node, filter);
            client.SelectedInstances[threadID] = model;
            Log("Request Instance: Model added for thread " + threadID.ToString());

            model.BeginUpdateTree(false);

            // send back details, columns, and nodes
            var response = new InstancePacket()
            {
                Type = InstancePacketType.Root,
                ThreadID = threadID,
                Details = model.DetailsLabel,
                Columns = model.Columns,
                Fields = model.RootNodes
            };

            client.Connection.SendPacket(response);
        }