public void InequalityOperator_ReturnsTrue_WhenFieldsDoNotMatch(JSendResponse <string> first, JSendResponse <string> second) { // Exercise system var areNotEqual = first != second; // Verify outcome areNotEqual.Should().BeTrue(); }
public JsonResult LoadVeConfig(int fieldId, int siteId) { var result = new JSendResponse { Status = JSendStatus.Success }; VisualEditorStyleVm StyleMapFn(VisualEditorStyle entry) => new VisualEditorStyleVm { Name = entry.Name, Element = entry.Tag, Overrides = entry.OverridesTag, Styles = entry.StylesItems.Any() ? entry.StylesItems.ToDictionary(k => k.Name.Replace(' ', '_'), v => v.ItemValue) : null, Attributes = entry.AttributeItems.Any() ? entry.AttributeItems.ToDictionary(k => k.Name, v => v.ItemValue) : null }; VisualEditorPluginVm PluginMapFn(VisualEditorPlugin entry) => new VisualEditorPluginVm { Name = entry.Name, Url = entry.Url }; var veCommands = FieldService.GetResultVisualEditorCommands(fieldId, siteId).Where(n => n.On).ToList(); var includedStyles = FieldService.GetResultStyles(fieldId, siteId).Where(ves => ves.On).OrderBy(ves => ves.Order).ToList(); var model = new VisualEditorConfigVm { StylesSet = includedStyles.Where(ves => !ves.IsFormat).Select(StyleMapFn), FormatsSet = includedStyles.Where(ves => ves.IsFormat).Select(StyleMapFn).EmptyIfNull(), ExtraPlugins = VisualEditorHelpers.GetVisualEditorPlugins(veCommands).Select(PluginMapFn).EmptyIfNull(), Toolbar = VisualEditorHelpers.GenerateToolbar(veCommands) }; if (fieldId != 0) { var field = FieldService.Read(fieldId); model.Language = field.VisualEditor.Language; model.DocType = field.VisualEditor.DocType; model.FullPage = field.VisualEditor.FullPage; model.EnterMode = field.VisualEditor.EnterMode; model.ShiftEnterMode = field.VisualEditor.ShiftEnterMode; model.UseEnglishQuotes = field.VisualEditor.UseEnglishQuotes; model.DisableListAutoWrap = field.VisualEditor.DisableListAutoWrap; model.Height = field.VisualEditor.Height; model.BodyClass = field.RootElementClass; model.ContentsCss = field.ExternalCssItems.Select(css => css.Url); } try { result.Data = model; } catch (Exception) { result.Status = JSendStatus.Error; result.Message = "Непредвиденная ошибка на сервере"; } return(JsonCamelCase(result)); }
public void InequalityOperator_IsSymmetric(JSendResponse <string> first, JSendResponse <string> second) { // Exercise system var firstEqualsSecond = first != second; var secondEqualsFirst = second != first; // Verify outcome firstEqualsSecond.Should().Be(secondEqualsFirst); }
public void Equals_IsSymmetric(JSendResponse <string> first, JSendResponse <string> second) { // Exercise system var firstEqualsSecond = first.Equals(second); var secondEqualsFirst = second.Equals(first); // Verify outcome firstEqualsSecond.Should().Be(secondEqualsFirst); }
public void InequalityOperator_ReturnsFalse_WhenBothResponsesAreNull() { #pragma warning disable 1718 // Fixture setup JSendResponse <string> response = null; // Exercise system var areNotEqual = response != response; // Verify outcome areNotEqual.Should().BeFalse(); #pragma warning restore 1718 }
public async Task SendAsync_ReturnsParsedResponse( HttpResponseMessage httpResponse, JSendResponse <Model> parsedResponse, [FrozenAsHttpClient] HttpClientStub httpClientStub, HttpRequestMessage request, [Greedy] JSendClient client) { // Fixture setup httpClientStub.ReturnOnSend = httpResponse; Mock.Get(client.Parser) .Setup(p => p.ParseAsync <Model>(It.IsAny <JsonSerializerSettings>(), httpResponse)) .ReturnsAsync(parsedResponse); // Exercise system var response = await client.SendAsync <Model>(request); // Verify outcome response.Should().BeSameAs(parsedResponse); }
public async Task Executes_OnParsed_WithCorrectContext( HttpRequestMessage request, [Frozen] HttpResponseMessage response, [Frozen] JSendResponse <object> jsendResponse, [Frozen] MessageInterceptor interceptor, [Greedy, MockHttpClient] JSendClient client) { // Exercise system await client.SendAsync <object>(request); // Verify outcome Mock.Get(interceptor) .Verify(i => i.OnParsed <object>( It.Is <ResponseParsedContext <object> >( ctx => ctx.HttpRequest == request && ctx.HttpResponse == response && ctx.JSendResponse == jsendResponse))); }
public void EqualResponsesHaveTheSameHashCode(JSendResponse <string> first, JSendResponse <string> second) { // Exercise system and verify outcome first.GetHashCode().Should().Be(second.GetHashCode()); }
public void TwoResponses_AreNotEqual_WhenTheirFieldsDoNotMatch(JSendResponse <string> first, JSendResponse <string> second) { // Exercise system and verify outcome first.Equals(second).Should().BeFalse(); }
public async Task SendAsync_ReturnsParsedResponse( HttpResponseMessage httpResponseMessage, JSendResponse<Model> parsedResponse, [FrozenAsHttpClient] HttpClientStub httpClientStub, HttpRequestMessage request, [Greedy] JSendClient client) { // Fixture setup httpClientStub.ReturnOnSend = httpResponseMessage; Mock.Get(client.Parser) .Setup(p => p.ParseAsync<Model>(It.IsAny<JsonSerializerSettings>(), httpResponseMessage)) .ReturnsAsync(parsedResponse); // Exercise system var response = await client.SendAsync<Model>(request); // Verify outcome response.Should().BeSameAs(parsedResponse); }