public void UpdatingDatabaseGood()
        {
            Mock <FileContent> fileContentDouble = new Mock <FileContent>();

            fileContent = fileContentDouble.Object;

            Mock <IFileContentController> fileContentContrellerDouble = new Mock <IFileContentController>();

            fileContentController = fileContentContrellerDouble.Object;

            Mock <Files> fileDouble = new Mock <Files>();

            fileDouble.Setup(fileproba => fileproba.Id).Returns("nestoBezveze");
            file = fileDouble.Object;

            Mock <IFileController> fileContrellerDouble = new Mock <IFileController>();

            fileContrellerDouble.Setup(controller => controller.Add(file)).Verifiable();


            Mock <IController> controllerDouble = new Mock <IController>();

            controller = controllerDouble.Object;

            UpdatingDatabase UpdateDouble = new  UpdatingDatabase();

            UpdateDouble.AddToDatabase(file, fileContent, fileContrellerDouble.Object, fileContentController);

            fileContrellerDouble.Verify(controller => controller.Add(file), Times.Once);
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            T items = new T();

            items.Data = "228";
            controller.Add(items);
        }
Esempio n. 3
0
 public ViewBase(IModel model, IController controller)
     : base()
 {
     _Observers  = new List <IObserver>();
     _Model      = model;
     _Controller = controller;
     _Controller.Add(this);
 }
Esempio n. 4
0
        public void UiInput()
        {
            StmtMenu();
            IStmt stmt = AddStmt(GetInputString());

            Console.WriteLine("You've added to program: ");
            Console.WriteLine(stmt.ToString());
            ctrl.Add(stmt);
        }
Esempio n. 5
0
 public async Task Add(DataSourceType dataSourceType, T source)
 {
     if (_controller != null)
     {
         if (typeof(T) == typeof(MapModel))
         {
             await _controller.Add(dataSourceType, source);
         }
         else if (typeof(T) == typeof(MapLocationModel))
         {
             MapLocationController controller = (MapLocationController)_controller;
             controller.MapId = MapId;
             await _controller.Add(DataSourceType.Sqlite, source);
         }
         else if (typeof(T) == typeof(MapLocationFolderModel))
         {
             MapLocationFolderController controller = (MapLocationFolderController)_controller;
             controller.MapLocationId = MapLocationId;
             await _controller.Add(DataSourceType.Sqlite, source);
         }
     }
 }
Esempio n. 6
0
        public void CreateNotice(string[] data, bool isGroup)
        {
            if (isGroup)
            {
                var members = _memberStore.List().Where(item => item.GroupId == int.Parse(data[0]));
                foreach (var member in members)
                {
                    _noticeController.Add(new Dictionary <string, string>()
                    {
                        { "ReceiverId", member.Id.ToString() }, { "Message", data[1] }
                    });
                }
            }
            else
            {
                _noticeController.Add(new Dictionary <string, string>()
                {
                    { "ReceiverId", data[0] }, { "Message", data[1] }
                });
            }

            Console.WriteLine("Notices sent successfully.");
            _logger.LogInformation("Notices sent successfully.");
        }
Esempio n. 7
0
        public void CreateRole(string name)
        {
            bool created = _roleController.Add(new Dictionary <string, string>()
            {
                { "name", name }
            });

            if (created)
            {
                Console.WriteLine("Role created successfully.");
                _logger.LogInformation($"Role with name {name} created successfully");
            }
            else
            {
                Console.WriteLine($"Command failed! Name {name} already exists. Try a different one.");
                _logger.LogError($"Command failed! Name {name} already exists. Try a different one.");
                ProcessCreate();
            }
        }
Esempio n. 8
0
        public void CreateGroup(string[] data)
        {
            bool created = _groupController.Add(new Dictionary <string, string>()
            {
                { "ChamaId", data[0] }, { "Name", data[1] }
            });

            if (created)
            {
                Console.WriteLine("Group created successfully.");
                _logger.LogInformation($"Group with name {data[1]} created successfully");
            }
            else
            {
                Console.WriteLine($"Command failed! Name {data[1]} already exists. Try a different one.");
                _logger.LogError($"Command failed! Name {data[1]} already exists. Try a different one.");
                fieldIdx = 0;
                ProcessCreate();
            }
        }
Esempio n. 9
0
        public bool CreateMember(Dictionary <string, string> data, bool imported = false)
        {
            bool created = _memberController.Add(data);

            if (created)
            {
                Console.WriteLine("Member created successfully.");
                _logger.LogInformation($"Member with name {data["FirstName"]} created successfully");
            }
            else
            {
                Console.WriteLine($"Command failed! PhoneNumber or EmailAddress already exists. Try again.");
                _logger.LogError($"Command failed! PhoneNumber or EmailAddress already exists. Try again.");
                if (!imported)
                {
                    fieldIdx = 0;
                    ProcessCreate();
                }
            }
            return(created);
        }
Esempio n. 10
0
        public void Load(string levelFileName)
        {
            this.levelFileName = levelFileName;

            List <string> controllerId = new List <string>();
            List <string> controlledId = new List <string>();

            XmlTextReader reader = new XmlTextReader("Content/level/" + levelFileName);

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "size")
                    {
                        string width            = reader.GetAttribute("width");
                        string height           = reader.GetAttribute("height");
                        string treasureCountStr = reader.GetAttribute("treasureCount");

                        int treasureCount = int.Parse(treasureCountStr);
                        this.width  = int.Parse(width);
                        this.height = int.Parse(height);

                        this.treasureMgr = new TreasureManager(this.levelFileName, treasureCount);
                    }
                    else if (reader.Name == "background")
                    {
                        backgroundTextureAssetName = reader.GetAttribute("texture");
                        string backgroundColorStr = reader.GetAttribute("color");
                        if (backgroundColorStr == "black")
                        {
                            backgroundColor = Color.Black;
                        }
                    }
                    else if (reader.Name == "foreground")
                    {
                        foregroundTextureAssetName = reader.GetAttribute("texture");
                        string bottom = reader.GetAttribute("bottom");
                    }
                    else if (reader.Name == "bound")
                    {
                        string leftStr   = reader.GetAttribute("left");
                        string rightStr  = reader.GetAttribute("right");
                        string topStr    = reader.GetAttribute("top");
                        string bottomStr = reader.GetAttribute("bottom");
                        leftBound   = int.Parse(leftStr);
                        rightBound  = int.Parse(rightStr);
                        topBound    = int.Parse(topStr);
                        bottomBound = int.Parse(bottomStr);
                        Block leftBoundBlock   = new Block(game, new Vector2(leftBound, 0), 0, height);
                        Block rightBoundBlock  = new Block(game, new Vector2(rightBound, 0), 0, height);
                        Block topBoundBlock    = new Block(game, new Vector2(0, topBound), width, 0);
                        Block bottomBoundBlock = new Block(game, new Vector2(0, bottomBound), width, 0);
                        objects.Add(leftBoundBlock);
                        objects.Add(rightBoundBlock);
                        objects.Add(topBoundBlock);
                        objects.Add(bottomBoundBlock);
                    }
                    else if (reader.Name == "player")
                    {
                        player = new Player(game, reader);
                    }
                    else if (reader.Name == "enemy")
                    {
                        Enemy enemy = new Enemy(game, reader);
                    }
                    else if (reader.Name == "shiftStick")
                    {
                        ShiftStick stick = new ShiftStick(game, reader);

                        XmlReader subtree = reader.ReadSubtree();
                        while (subtree.Read())
                        {
                            if (subtree.NodeType == XmlNodeType.Element &&
                                subtree.Name == "controlled")
                            {
                                controllerId.Add(stick.Id);
                                controlledId.Add(subtree.GetAttribute("objId"));
                            }
                        }
                    }
                    else if (reader.Name == "lightsource")
                    {
                        LightSource light1 = new LightSource(game, reader);
                        lightSource.Add(light1);
                    }
                    else if (reader.Name == "mirror")
                    {
                        Mirror mirror1 = new Mirror(game, reader);
                    }
                    else if (reader.Name == "switch")
                    {
                        Switch switch1 = new Switch(game, reader);

                        XmlReader subtree = reader.ReadSubtree();
                        while (subtree.Read())
                        {
                            if (subtree.NodeType == XmlNodeType.Element &&
                                subtree.Name == "controlled")
                            {
                                controllerId.Add(switch1.Id);
                                controlledId.Add(subtree.GetAttribute("objId"));
                            }
                        }
                    }
                    else if (reader.Name == "ladder")
                    {
                        Ladder ladder = new Ladder(game, reader);
                    }
                    else if (reader.Name == "door")
                    {
                        Door door = new Door(game, reader);
                    }
                    else if (reader.Name == "platform")
                    {
                        Platform platform = new Platform(game, reader);
                    }
                    else if (reader.Name == "block")
                    {
                        Block block = new Block(game, reader);
                    }
                    else if (reader.Name == "launcher")
                    {
                        Launcher launcher = new Launcher(game, reader);
                    }
                    else if (reader.Name == "treasure")
                    {
                        Treasure      treasure;
                        bool          flag = false;
                        List <String> ids  = this.treasureMgr.AreGotten();
                        foreach (String id in ids)
                        {
                            if (reader.GetAttribute("id") == id)
                            {
                                treasure = new Treasure(game, reader, true);
                                flag     = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            treasure = new Treasure(game, reader, false);
                        }
                    }
                    else if (reader.Name == "deadlyobj")
                    {
                        DeadlyObject deadlyobj = new DeadlyObject(game, reader);
                    }
                    else if (reader.Name == "ogre")
                    {
                        Ogre ogre = new Ogre(game, reader);
                    }
                    else if (reader.Name == "gate")
                    {
                        Gate gate = new Gate(game, reader);
                    }
                    else if (reader.Name == "topic")
                    {
                        string pxStr = reader.GetAttribute("px");
                        string pyStr = reader.GetAttribute("py");

                        topic = reader.ReadElementString();

                        float px = float.Parse(pxStr);
                        float py = float.Parse(pyStr);
                        topicPos = new Vector2(px, py);
                    }
                    else if (reader.Name == "bindingPoint")
                    {
                        if (Game.BindingPoint == null)
                        {
                            Game.BindingPoint = new BindingPoint();
                            XmlReader subtree = reader.ReadSubtree();
                            while (subtree.Read())
                            {
                                if (subtree.NodeType == XmlNodeType.Element &&
                                    subtree.Name == "p")
                                {
                                    string pxStr = subtree.GetAttribute("px");
                                    string pyStr = subtree.GetAttribute("py");
                                    string id    = subtree.GetAttribute("id");

                                    Vector2 pos = new Vector2(int.Parse(pxStr), int.Parse(pyStr));
                                    Game.BindingPoint.Add(pos, levelFileName, id);
                                }
                            }
                        }
                    }
                }
            }

            reader.Close();

            List <string> .Enumerator controllerEnum = controllerId.GetEnumerator();
            List <string> .Enumerator controlledEnum = controlledId.GetEnumerator();
            while (controllerEnum.MoveNext() && controlledEnum.MoveNext())
            {
                string            controllerStr = controllerEnum.Current;
                string            controlledStr = controlledEnum.Current;
                IController       controller    = (IController)GetObjectById(controllerStr);
                IControlledObject controlled    = (IControlledObject)GetObjectById(controlledStr);
                controller.Add(controlled);
            }

            Initialize();
            LoadContent();
        }