public void DeserializeButtonClickEvent() { /* GIVEN */ string eventJson = "{\"buttonTitle\":\"SomeText\",\"buttonHref\":\"https://sample.com/redirect\",\"tabID\":5,\"url\":\"https://sample.com\",\"timeStamp\":\"2020-03-05T10:10:51.1230000+01:00\"}"; var deserialized = new ButtonClickEvent(); /* WHEN */ deserialized.Deserialize(eventJson); /* THEN */ TestCommonAttributes(deserialized); Assert.AreEqual(commonText, deserialized.Button); Assert.AreEqual("https://sample.com/redirect", deserialized.Href); }
//verify that senddata-request is correctly handled public async Task SendData() { // Preconditions webBrowserModule.Initialize(true); webBrowserModule.IsActive = true; var data = new { buttonTitle = "SomeText", buttonHref = "https://sample.com/redirect", tabID = 5, url = "https://sample.com", timeStamp = new DateTime(2015, 5, 6, 7, 8, 9, 512, DateTimeKind.Utc), type = "BUTTONCLICK" }; /* WHEN */ var result = await SendHTTPMessage(new { Request = "SendData", Data = data }); /* THEN */ Assert.AreEqual(StringConstants.okString, result.GetProperty("response").GetString()); Assert.AreEqual(StringConstants.appIdentifier, result.GetProperty("application").GetString()); buttonClickEventProducer.Verify(mock => mock.Notify(It.IsAny <JsonElement>()), Times.Once); Assert.IsNotNull(lastJson); var parsedEvent = new ButtonClickEvent(); parsedEvent.Deserialize((JsonElement)lastJson); Assert.AreEqual(data.timeStamp.ToUniversalTime(), parsedEvent.Timestamp.ToUniversalTime()); Assert.AreEqual(data.buttonTitle, parsedEvent.Button); Assert.AreEqual(data.buttonHref, parsedEvent.Href); Assert.AreEqual(data.tabID, parsedEvent.TabID); Assert.AreEqual(new Uri(data.url), parsedEvent.CurrentURL); }