13 | @if (description.Documentation != null)
14 | {
15 |
@description.Documentation
16 | }
17 | else
18 | {
19 |
No documentation available.
20 | }
21 |
22 | @if (hasParameters || hasRequestSamples)
23 | {
24 |
Request Information
25 | if (hasParameters)
26 | {
27 |
Parameters
28 | @Html.DisplayFor(apiModel => apiModel.ApiDescription.ParameterDescriptions, "Parameters")
29 | }
30 | if (hasRequestSamples)
31 | {
32 |
Request body formats
33 | @Html.DisplayFor(apiModel => apiModel.SampleRequests, "Samples")
34 | }
35 | }
36 |
37 | @if (hasResponseSamples)
38 | {
39 |
Response Information
40 | if (description.ResponseDescription.Documentation != null)
41 | {
42 |
@description.ResponseDescription.Documentation
43 | }
44 | else
45 | {
46 |
No documentation available.
47 | }
48 |
Response body formats
49 | @Html.DisplayFor(apiModel => apiModel.SampleResponses, "Samples")
50 | }
51 |
--------------------------------------------------------------------------------
/AddisCode.SOLIDTraining/AddisCode.SolidPrinciple.Lsp.Principles/CarUnitTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using AddisCode.SolidPrinciple.Lsp.Principles.Entities;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace AddisCode.SolidPrinciple.Lsp.Principles
7 | {
8 | [TestClass]
9 | public class CarUnitTest
10 | {
11 | [TestMethod]
12 | public void Make_sure_car_can_start()
13 | {
14 | var car = new Car(Color.Aqua);
15 | //var car = new BrokenCar(Color.Aqua); //Post condition Weakened
16 | //var car = new CrimeBossCar(Color.Aqua, true); //Throws new type of exception
17 | try
18 | {
19 | car.StartEngine();
20 | }
21 | catch (OutOfFuelException)
22 | {
23 | Assert.Fail("Car is out of gas....");
24 | }
25 | Assert.IsTrue(car.IsEngineRunning);
26 | }
27 |
28 | [TestMethod]
29 | public void Make_sure_engine_is_running_after_start()
30 | {
31 | var car = new Car(Color.Aqua);
32 | //var car = new Prius(Color.Aqua); // Changing invariants
33 | //var car = new StolenCar(Color.Aqua); // Changing preconditions
34 |
35 | car.StartEngine();
36 |
37 | Assert.IsTrue(car.IsEngineRunning);
38 | }
39 |
40 | [TestMethod]
41 | public void Make_sure_the_car_is_painted_correctly()
42 | {
43 | var car = new Car(Color.Aqua);
44 | //var car = new PimpedCar(Color.Aqua); // Violating history constraint
45 | //car.setTempreture(30);
46 |
47 | Assert.AreEqual(Color.Aqua, car.Color);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/AddisCode.SOLIDTraining/AddisCode.SolidPrinciple.Lsp/FormatConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace AddisCode.SolidPrinciple.Lsp
5 | {
6 | class FormatConverter
7 | {
8 | private readonly InputParser _inputParser;
9 | private readonly IDocumentSerializer _documentSerializer;
10 |
11 | public FormatConverter()
12 | {
13 | //_documentSerializer = new CamleCaseJsonSerializer();
14 | _documentSerializer = new JsonDocumentSerializer();
15 | //_inputParser = new InputParser();
16 | _inputParser = new XmlInputParser();
17 | }
18 | internal bool ConvertFormat(string sourceFileName, string targetFileName)
19 | {
20 | string input;
21 | var documentStorage = GetDocumentStorage(sourceFileName);
22 | try
23 | {
24 | input = documentStorage.GetData(sourceFileName);
25 | }
26 | catch (FileNotFoundException)
27 | {
28 | return false;
29 | }
30 |
31 | var doc = _inputParser.ParseInput(input);
32 | var serializedDoc = _documentSerializer.Serilize(doc);
33 |
34 | try
35 | {
36 | documentStorage.PersistDocument(serializedDoc, targetFileName);
37 | }
38 | catch (AccessViolationException)
39 | {
40 | return false;
41 | }
42 | return true;
43 | }
44 |
45 | internal DocumentStorage GetDocumentStorage(string sourceFileName)
46 | {
47 | if (sourceFileName.StartsWith("http"))
48 | return new HttpInputRetriever();
49 | return new FileDocumentStorage();
50 | }
51 |
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/AddisCode.SOLIDTraining/AddisCode.SolidPrinciple.Ocp/FormatConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace AddisCode.SolidPrinciple.Ocp
5 | {
6 | class FormatConverter
7 | {
8 | private readonly InputParser _inputParser;
9 | private readonly IDocumentSerializer _documentSerializer;
10 |
11 | public FormatConverter()
12 | {
13 | //_documentSerializer = new CamleCaseJsonSerializer();
14 | _documentSerializer = new JsonDocumentSerializer();
15 | //_inputParser = new InputParser();
16 | _inputParser = new XmlInputParser();
17 | }
18 | internal bool ConvertFormat(string sourceFileName, string targetFileName)
19 | {
20 | string input;
21 | var documentStorage = GetDocumentStorage(sourceFileName);
22 | try
23 | {
24 | input = documentStorage.GetData(sourceFileName);
25 | }
26 | catch (FileNotFoundException)
27 | {
28 | return false;
29 | }
30 |
31 | var doc = _inputParser.ParseInput(input);
32 | var serializedDoc = _documentSerializer.Serilize(doc);
33 |
34 | try
35 | {
36 | documentStorage.PersistDocument(serializedDoc, targetFileName);
37 | }
38 | catch (AccessViolationException)
39 | {
40 | return false;
41 | }
42 | return true;
43 | }
44 |
45 | internal DocumentStorage GetDocumentStorage(string sourceFileName)
46 | {
47 | if (sourceFileName.StartsWith("http"))
48 | return new HttpInputRetriever();
49 | return new FileDocumentStorage();
50 | }
51 |
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/AddisCode.SOLIDTraining/RestDataCenter/Views/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |