コード例 #1
0
        public async void BulkInsert_No_Errors()
        {
            LinkControllerMockFacade mock = new LinkControllerMockFacade();

            var mockResponse = new CreateResponse <ApiLinkResponseModel>(new FluentValidation.Results.ValidationResult());

            mockResponse.SetRecord(new ApiLinkResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiLinkRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiLinkResponseModel> >(mockResponse));
            LinkController controller = new LinkController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var records = new List <ApiLinkRequestModel>();

            records.Add(new ApiLinkRequestModel());
            IActionResult response = await controller.BulkInsert(records);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var result = (response as OkObjectResult).Value as List <ApiLinkResponseModel>;

            result.Should().NotBeEmpty();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiLinkRequestModel>()));
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (filePath != "")
            {
                //check exists
                Note noteCheck = NoteController.getNote(filePath);
                noteCheck.note = txtNote.Text;

                List <Link> listLink = LinkController.getListLinks(filePath);

                if (listKind != null)
                {
                    for (int i = 0; i < listLink.Count; i++)
                    {
                        Link link = listLink[i];
                        LinkController.deleteLink(link);
                    }
                }

                for (int i = 0; i < lbChooseKind.Items.Count; i++)
                {
                    Link link = new Link();
                    link.kind = lbChooseKind.Items[i].ToString();
                    link.note = filePath;
                    LinkController.addLink(link);
                }

                NoteController.updateNote(noteCheck);
            }
        }
コード例 #3
0
            //------------------------------------------------------------------------/
            // Initialization
            //------------------------------------------------------------------------/
            /// <summary>
            /// Initializes the LinkInterface, subscribing to all link navigation
            /// events, registering the link controller, etc...
            /// </summary>
            void Awake()
            {
                this.gameObject.Connect <Link.NavigateEvent>(this.OnNavigateEvent);
                this.gameObject.Connect <Link.ConfirmEvent>(this.OnConfirmEvent);
                this.gameObject.Connect <Link.CancelEvent>(this.OnCancelEvent);
                this.gameObject.Connect <Link.OpenedEvent>(this.OnLinkOpenedEvent);
                this.gameObject.Connect <Link.ClosedEvent>(this.OnLinkClosedEvent);
                this.gameObject.Connect <Link.SelectEvent>(this.OnLinkSelectEvent);

                // Look for the LinkController among the children
                Controller = GetComponentInChildren <LinkController>();
                if (Controller)
                {
                    Controller.Connect(this);
                }

                // Initialize the interface subclass
                this.OnInterfaceInitialize();

                // If it's already active, open it
                if (Active)
                {
                    this.Open();
                }
                // Otherwise hide everyhting
                else
                {
                    ToggleGraphics(false);
                    ToggleControls(false, true);
                }
            }
コード例 #4
0
        public async void Patch_No_Errors()
        {
            LinkControllerMockFacade mock = new LinkControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiLinkResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(true);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ApiLinkRequestModel>()))
            .Callback <int, ApiLinkRequestModel>(
                (id, model) => model.AssignedMachineId.Should().Be(1)
                )
            .Returns(Task.FromResult <UpdateResponse <ApiLinkResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiLinkResponseModel>(new ApiLinkResponseModel()));
            LinkController controller = new LinkController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiLinkModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var patch = new JsonPatchDocument <ApiLinkRequestModel>();

            patch.Replace(x => x.AssignedMachineId, 1);

            IActionResult response = await controller.Patch(default(int), patch);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            mock.ServiceMock.Verify(x => x.Update(It.IsAny <int>(), It.IsAny <ApiLinkRequestModel>()));
        }
コード例 #5
0
 void Awake()
 {
     if (retryButton == null)
     {
         Debug.Log("retryButton == null");
     }
     if (detailButton == null)
     {
         Debug.Log("detailButton == null");
     }
     if (detailPanel == null)
     {
         Debug.Log("detailPanel == null");
     }
     if (pauseButton == null)
     {
         Debug.Log("pauseButton == null");
     }
     if (remainingWordlist == null)
     {
         Debug.Log("remainingWOrdlist == null");
     }
     if (timer == null)
     {
         Debug.Log("timer == null");
     }
     tileManager    = TileManager.GetInstance();
     wordChecker    = WordChecker.GetInstance();
     linkController = LinkController.GetInstance();
 }
コード例 #6
0
        /// <summary>
        ///         ''' Try to retrieve meta description and title from the url specified
        ///         ''' </summary>
        ///         ''' <param name="sender"></param>
        ///         ''' <param name="e"></param>
        ///         ''' <remarks></remarks>
        ///         ''' <history>
        ///         '''     [alex]      10/02/2009   First implementation
        ///         ''' </history>
        protected void lbtGetContent_Click(object sender, System.EventArgs e)
        {
            string targetUrl = this.ctlURL.Url;

            if (!string.IsNullOrEmpty(targetUrl))
            {
                string retrieveMessage         = Localization.GetString("msgGetContentSucceeded.Text", this.LocalResourceFile);
                string retrieveMessageCssClass = "MessageSuccees";

                try
                {
                    // get content from target url
                    TargetInfo targetInfo = LinkController.GetTargetContent(targetUrl);

                    this.txtTitle.Text       = targetInfo.Title;
                    this.txtDescription.Text = targetInfo.Description;
                }
                catch (System.Net.WebException)
                {
                    retrieveMessage         = Localization.GetString("msgGetContentFailed.Text", this.LocalResourceFile);
                    retrieveMessageCssClass = "MessageFailure";
                }

                lblGetContentResult.Text     = retrieveMessage;
                lblGetContentResult.CssClass = retrieveMessageCssClass;

                valTitle.Validate();
            }
        }
コード例 #7
0
 void ApplyStyles(LinkController linkController)
 {
     if (GUILayout.Button("Apply Styles"))
     {
         linkController.ApplyStyles();
     }
 }
コード例 #8
0
        public void Should_save_a_link_with_specified_url_and_the_returned_id()
        {
            var saveLink = Substitute.For <ISaveLinks>();
            var sut      = new LinkController(Substitute.For <IRetrieveLinks>(), saveLink);

            var id = sut.Create("http://example.com").CreatedLinkId();

            saveLink.Received().WithIdAndUrl(id, new Uri("http://example.com"));
        }
コード例 #9
0
    // This will take out player health when player touches the spk
    void OnTriggerStay2D(Collider2D other)
    {
        LinkController controller = other.GetComponent <LinkController>();

        if (controller != null)
        {
            controller.changeHealth(-1);
        }
    }
コード例 #10
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        LinkController controller = other.gameObject.GetComponent <LinkController>();

        if (controller != null)
        {
            controller.ChangeHealth(-1);
        }
    }
コード例 #11
0
    public string scene;        // Current scene

    public PlayerData(GameObject player)
    {
        LinkController link = player.gameObject.GetComponent <LinkController>();                 // This gets the main characters attributes for data manipulation.

        health      = link.health;
        scene       = link.getScene();
        position    = new float[2];
        position[0] = player.transform.position.x;                      // Players x coordinate
        position[1] = player.transform.position.y;                      // Players y coordinate
    }
        public void Should_return_an_http_bad_request_result(string url)
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Create(url);

            result.Should().BeOfType <BadRequestObjectResult>();
        }
コード例 #13
0
ファイル: DoorScript.cs プロジェクト: kpmcarthur/ZeldaUnity
    private void OnTriggerEnter2D(Collider2D other)
    {
        LinkController controller = other.gameObject.GetComponent <LinkController>();

        if (controller != null)
        {
            cam.Move(camChange);
            controller.RoomChange(playerChange);
        }
    }
コード例 #14
0
        public void Should_return_an_http_not_found_result()
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Metadata("unknown-link-id");

            result.Should().BeOfType <NotFoundResult>();
        }
コード例 #15
0
        public void Should_return_an_http_created_result()
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Create("http://example.com");

            result.StatusCode().Should().Be(201);
        }
        public void Should_return_an_http_bad_request_result_even_with_a_provided_id(string url)
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Create(id: "example", url);

            result.Should().BeOfType <BadRequestObjectResult>();
        }
コード例 #17
0
        public void Should_return_an_http_created_result()
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Create("example", "http://example.com");

            result.Should().BeOfType <CreatedAtRouteNegotiatedContentResult <string> >();
        }
コード例 #18
0
        public void Should_return_an_http_moved_result()
        {
            var getLink = Substitute.For <IRetrieveLinks>();

            getLink.WithId("id").Returns(new Link("id,", "http://example.com"));
            var sut = new LinkController(getLink, Substitute.For <ISaveLinks>());

            var result = sut.Follow("id");

            result.Should().BeOfType <RedirectResult>();
        }
コード例 #19
0
        public void Should_return_the_generated_id_of_the_created_link()
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Create("http://example.com");

            result.Should().BeOfType <CreatedAtRouteResult>()
            .Which.RouteValues.Should().ContainKey("id").And.NotBeNull();
        }
        public void Should_return_an_http_ok_result()
        {
            var getLink = Substitute.For <IRetrieveLinks>();

            getLink.WithId("id").Returns(new Link("id,", "http://example.com"));
            var sut = new LinkController(getLink, Substitute.For <ISaveLinks>());

            var result = sut.Metadata("id");

            result.StatusCode().Should().Be(200);
        }
コード例 #21
0
        public void Should_return_the_url_of_the_created_link()
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Create("http://example.com");

            result.Should().BeOfType <CreatedAtRouteResult>()
            .Which.Value.Should().Be("http://example.com");
        }
コード例 #22
0
        public void Should_return_an_http_ok_result()
        {
            var getLink = Substitute.For <IRetrieveLinks>();

            getLink.WithId("id").Returns(new Link("id,", "http://example.com"));
            var sut = new LinkController(getLink, Substitute.For <ISaveLinks>());

            var result = sut.Metadata("id");

            result.Should().BeOfType <OkNegotiatedContentResult <Link> >();
        }
コード例 #23
0
        public void Should_return_the_href_of_the_link()
        {
            var getLink = Substitute.For <IRetrieveLinks>();

            getLink.WithId("id").Returns(new Link("id,", "http://example.com"));
            var sut = new LinkController(getLink, Substitute.For <ISaveLinks>());

            var result = sut.Metadata("id");

            result.ContentAs <Link>().Href.Should().Be("http://example.com");
        }
コード例 #24
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        LinkController controller = other.GetComponent <LinkController>();

        if (controller != null && collectible)
        {
            // Do something

            Destroy(gameObject);
        }
    }
コード例 #25
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        LinkController controller = other.GetComponent <LinkController>();

        if (controller != null && collectible)
        {
            controller.ChangeRupeeCount(amount);

            Destroy(gameObject);
        }
    }
コード例 #26
0
        public void Should_save_a_link_with_the_specified_id_and_url()
        {
            var saveLink = Substitute.For <ISaveLinks>();
            var sut      = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                saveLink);

            var result = sut.Create("id", "http://example.com");

            saveLink.Received().WithIdAndUrl("id", new Uri("http://example.com"));
        }
コード例 #27
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        LinkController controller = other.gameObject.GetComponent <LinkController>();

        if (controller != null)
        {
            grabbed = true;
            Vector2 position = rigidbody2d.position;
            controller.transform.position = controller.startPosition;
        }
    }
コード例 #28
0
        public void Should_return_the_id_of_the_created_link()
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Create("example", "http://example.com");

            result.Should().BeOfType <CreatedAtRouteNegotiatedContentResult <string> >()
            .Which.RouteValues.Should().ContainKey("id").And.ContainValue("example");
        }
コード例 #29
0
        public void Should_return_the_route_name_for_the_created_link()
        {
            var sut = new LinkController(
                Substitute.For <IRetrieveLinks>(),
                Substitute.For <ISaveLinks>());

            var result = sut.Create("example", "http://example.com");

            result.Should().BeOfType <CreatedAtRouteNegotiatedContentResult <string> >()
            .Which.RouteName.Should().Be("Follow");
        }
コード例 #30
0
        public void Should_return_the_url_of_the_link()
        {
            var getLink = Substitute.For <IRetrieveLinks>();

            getLink.WithId("id").Returns(new Link("id,", "http://example.com"));
            var sut = new LinkController(getLink, Substitute.For <ISaveLinks>());

            var result = sut.Follow("id");

            result.Should().BeOfType <RedirectResult>()
            .Which.Location.Should().Be("http://example.com/");
        }
コード例 #31
0
 //-------------------------------------------------------------------------------------
 public void AddNewPort(ConnectionType cType, LinkController link)
 {
     if (cType == ConnectionType.cEthernet)
     {
         this.interfaceName.Add("Ethernet-"+(this.countEthernet + 1));
         this.interfaceDescription.Add("Ethernet-" + (this.countEthernet + 1));
         this.countEthernet++;
     }
     else
     {
         this.interfaceName.Add("Serial-" + (this.countSerial + 1));
         this.interfaceDescription.Add("Serial-" + (this.countSerial + 1));
         this.countSerial++;
     }
     this.ipAdresses.Add("127.0.0.1"); ;
     this.masksOctets.Add("255.255.255.0");
     this.connected.Add(link) ;
 }
コード例 #32
0
        //-----------------------------------------------------------------------------
        /// <summary>
        /// Add Connection
        /// </summary>
        /// <param name="from">from device</param>
        /// <param name="to"> to device</param>
        public void AddLink(DeviceController from, DeviceController to)
        {
            //delete temo line
            canvas.Children.Remove(tempLine);
            canvas.Children.Remove(leftLine);
            canvas.Children.Remove(rightLine);
            canvas.Children.Remove(startLeftLine);
            canvas.Children.Remove(startRightLine);

            if (from == to)
            {
                firstDevice = null;
                FinishAddLink();
                to.UpdateCursor();
                UpdateIsClear();
                return;
            }
            //create
            LinkController link = new LinkController(this, from, to, this.cType);
            //add connections
            from.AddNewPort(this.cType,link);
            if (OnUpdateDatagrid != null)
            {
                OnUpdateDatagrid(from);
            }
            to.AddNewPort(this.cType, link);
            if (OnUpdateDatagrid != null)
            {
                OnUpdateDatagrid(to);
            }

            if (from != to)
            {
                linkList.Add(link);
                if (this.cType == ConnectionType.cEthernet)
                {
                    OnHistoryMessage("Добавлено новое соединение типа Ethernet между "+ from.DeviceValue + " и " + to.DeviceValue, true);
                }
                else
                {
                    OnHistoryMessage("Добавлено новое соединение типа Serial между " + from.DeviceValue + " и " + to.DeviceValue, true);
                }
            }
            firstDevice = null;
            FinishAddLink();
            to.UpdateCursor();
            UpdateIsClear();
        }
コード例 #33
0
        //-----------------------------------------------------------------------------
        /// <summary>
        /// Delete connection
        /// </summary>
        /// <param name="link"></param>
        public void DeleteLink(LinkController link)
        {
            int indexFrom = link.From.Connected.IndexOf(link);
            int indexTo = link.To.Connected.IndexOf(link);

            if (indexFrom != -1 && indexTo != -1)
            {
                link.From.DeletePort(indexFrom);
                link.To.DeletePort(indexTo);
            }
            if (OnUpdateDatagrid != null)
            {
                OnUpdateDatagrid(link.From);
            }
            if (OnUpdateDatagrid != null)
            {
                OnUpdateDatagrid(link.To);
            }
            if (linkList.Contains(link))
            {
                linkList.Remove(link);
                foreach (Shape shape in link.Edge)
                {
                    canvas.Children.Remove(shape);
                }
                if (link.CType == ConnectionType.cEthernet)
                {
                    OnHistoryMessage("Удалено соединение типа Ethernet между " + link.From.DeviceValue + " и " + link.To.DeviceValue, true);
                }
                else
                {
                    OnHistoryMessage("Удалено соединение типа Serial между " + link.From.DeviceValue + " и " + link.To.DeviceValue, true);
                }
            }
            UpdateIsClear();
        }