public void TestEquals() { OptionStrict <int> option = 1000.ToOptionStrict(); OptionStrict <int> option2 = 1000.ToOptionStrict(); Assert.True(option == option2); }
public VisualBasicProjectOptions WithOptionStrict(OptionStrict optionStrict) { var compilationOptions = (VisualBasicCompilationOptions)CompilationOptions; return(new VisualBasicProjectOptions( MetadataReferences, new VisualBasicCompilationOptions(compilationOptions.OutputKind, optionStrict: optionStrict))); }
private TResult GetResult(OptionStrict <int> timeout) { //Obtains the HTTP response var response = restClientExecuter.Execute(new Uri(host), GetRequest(timeout)); //Given said response, obtains the final result return(GetResultFromResponse(response)); }
private static void VerifyAnalyzer(string snippit, OptionStrict optionStrict) { var project = SolutionBuilder.Create().AddProject(AnalyzerLanguage.VisualBasic).AddSnippet(snippit); var options = new VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optionStrict: optionStrict); var compilation = project.GetCompilation(null, options); DiagnosticVerifier.Verify(compilation, new OptionStrictOn(), CompilationErrorBehavior.Default); }
public void WhenNothingAndClassTypeThenSerializesOk() { // Arrange OptionStrict <OptionConverterExample1> data = OptionStrict <OptionConverterExample1> .Nothing; // Act string json = jsonSerializer.SerializeObject(data); // Assert Assert.AreEqual("null", json); }
public void WhenNothingAndPrimitiveTypeThenSerializesOk() { // Arrange OptionStrict <int> data = OptionStrict <int> .Nothing; // Act string json = jsonSerializer.SerializeObject(data); // Assert Assert.AreEqual("null", json); }
public void WhenJustAndPrimitiveTypeThenSerializesOk() { // Arrange OptionStrict <int> data = 10; // Act string json = jsonSerializer.SerializeObject(data); // Assert Assert.AreEqual("10", json); }
public void WhenNestedOptionThenSerializesOkCase3() { // Arrange OptionStrict <OptionStrict <int> > data = OptionStrict <OptionStrict <int> > .Nothing; // Act string json = jsonSerializer.SerializeObject(data); // Assert Assert.AreEqual("null", json); }
public void WhenOptionNothingThenDictionaryWithNothing() { serializer.AddConverter(new DictionaryConverters.OptionConverter()); // act OptionStrict <object> optValue = OptionStrict <object> .Nothing; var result = serializer.SerializeObject(optValue); // assert Assert.AreEqual(1, result.Count, "Serialización de {0}", optValue); Assert.IsTrue(result.ContainsKey("Nothing")); Assert.AreEqual(string.Empty, result["Nothing"]); }
public RestClientBuilder(TSerializer serializer, TSerializer errorSerializer, IRestClientExecuter restClientExecuter, string host, string path, OptionStrict <object> data, Method method, Func <Processors.ExceptionProcessor <TResult, RestBusinessError, RestException, TSerializer> > exProcesorCreator) { this.host = host; this.path = path; this.data = data; this.method = method; this.serializer = serializer; this.errorSerializer = errorSerializer; this.processor = new ProcessorStructure <TResult, TSerializer>(); this.certificateList = new List <X509Certificate>(); this.headers = new List <RestSharp.HttpHeader>(); this.restClientExecuter = restClientExecuter; this.exProcesorCreator = exProcesorCreator; this.proxy = OptionStrict <System.Net.IWebProxy> .Nothing; }
public void WhenSimpleTypeThen() { //TODO: This fails with Stackoverflow OptionStrict <SimpleType> test = OptionStrict <SimpleType> .Nothing; var values01 = new Dictionary <OptionStrict <SimpleType>, Dictionary <string, string> > { { test, new Dictionary <string, string> { { string.Empty, null } } }, }; var values1 = new Dictionary <OptionStrict <SimpleType>, Dictionary <string, string> > { { OptionStrict <SimpleType> .Nothing, new Dictionary <string, string> { { string.Empty, null } } }, }; // arrange var values = new Dictionary <OptionStrict <SimpleType>, Dictionary <string, string> > { { OptionStrict <SimpleType> .Nothing, new Dictionary <string, string> { { string.Empty, null } } }, { new SimpleType(), new Dictionary <string, string> { { "EmptyType", null } } }, { new SimpleType { EmptyType = new EmptyType() }, new Dictionary <string, string> { { "EmptyType", "" } } }, }; foreach (var value in values) { // act var result = serializer.SerializeObject(value.Key.HasValue ? value.Key : (SimpleType)null); // assert Assert.AreEqual(value.Value.Count, result.Count); foreach (var item in value.Value) { Assert.IsTrue(result.ContainsKey(item.Key)); Assert.AreEqual(item.Value, result[item.Key]); } } }
public IRestRequest GetRequest(OptionStrict <int> timeout) { return(new RestRequest() { Proxy = proxy, Method = method, Resource = path, Certificates = certificateList, Headers = headers, Body = from dataValue in data select new Body { Format = serializer.Format, Content = serializer.SerializeObject(dataValue) }, Timeout = timeout }); }
public VisualBasicWorkspaceFactory WithOptionStrict(OptionStrict optionStrict) { return(new VisualBasicWorkspaceFactory(VisualBasicProjectOptions.WithOptionStrict(optionStrict))); }
public IRestClientBuilder <TResult, TSerializer> SetProxy(System.Net.IWebProxy proxy) { this.proxy = new JustStrict <System.Net.IWebProxy>(proxy); return(this); }
private IRestClientBuilder <TResult, TSerializer> CreateBuilder <TResult>(string host, string path, OptionStrict <object> data, Method method) { return(new RestClientBuilder <TResult, TSerializer>( CreateSuccessSerializer(), CreateErrorSerializer(), restClientExecuter, host, path, data, method, () => ObtainExceptionProcessor <TResult>())); }
/// <summary> /// Converts the HTTP error to a business error. If there is no error, then it uses default values from the response. /// </summary> /// <param name="errorRest">Error from the response</param> /// <param name="response">Response from the server</param> /// <returns>Corresponding business error</returns> public TRestBusinessError ProvideError(OptionStrict <TRestHttpError> errorRest, IRestResponse response) { var result = errorRest.HasValue ? errorRest.Value : WhenCantDeserializeError(response); return(result.ToBusinessError()); }