Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from NCAR/Tests
Browse files Browse the repository at this point in the history
Addition of tests for the controllers and code coverage report
  • Loading branch information
ecyr20 authored Apr 25, 2024
2 parents 9fc28eb + fc5cccf commit 85b3eaa
Show file tree
Hide file tree
Showing 320 changed files with 62,614 additions and 379 deletions.
Binary file modified .vs/Chemistry Cafe API/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/Chemistry Cafe API/v17/.futdcache.v2
Binary file not shown.
Binary file modified .vs/Chemistry Cafe API/v17/.suo
Binary file not shown.
168 changes: 163 additions & 5 deletions .vs/Chemistry Cafe API/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,181 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\College_Stuff\\2024_Spring\\CSCE482\\Project\\chemistry-cafe-api\\",
"Documents": [],
"WorkspaceRootPath": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\chemistry cafe api.http||{5703B403-55E7-4C63-8C88-A8F52C7A45C5}",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:chemistry cafe api.http||{5703B403-55E7-4C63-8C88-A8F52C7A45C5}"
},
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\dynamiccodecoverage.coveragexml||{FA3CD31E-987B-443A-9B81-186104E8DAC1}",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:dynamiccodecoverage.coveragexml||{FA3CD31E-987B-443A-9B81-186104E8DAC1}"
},
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\chemistry cafe api.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:chemistry cafe api.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
},
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\test.coverage||{25834150-CD7E-11D0-92DF-00A0C9138C45}",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:test.coverage||{25834150-CD7E-11D0-92DF-00A0C9138C45}"
},
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\appsettings.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:appsettings.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
},
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\chemistry cafe api.csproj||{04B8AB82-A572-4FEF-95CE-5222444B6B64}|",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:chemistry cafe api.csproj||{04B8AB82-A572-4FEF-95CE-5222444B6B64}|"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Evan\\.nuget\\packages\\reportgenerator\\5.2.5\\Readme.txt||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\testresults\\bebeeb31-5fa4-4b64-b3ed-85c033f075be\\evan_desktop-j5ql00b_2024-04-23.15_06_43.coverage||{25834150-CD7E-11D0-92DF-00A0C9138C45}",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:testresults\\bebeeb31-5fa4-4b64-b3ed-85c033f075be\\evan_desktop-j5ql00b_2024-04-23.15_06_43.coverage||{25834150-CD7E-11D0-92DF-00A0C9138C45}"
},
{
"AbsoluteMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|c:\\users\\evan\\documents\\github\\chemistry-cafe-api\\services\\openatmosservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{62738D41-607A-4727-AADD-D4B41BA734C9}|Chemistry Cafe API.csproj|solutionrelative:services\\openatmosservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": -1,
"SelectedChildIndex": 9,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{0174dea2-fdbe-4ef1-8f99-c0beae78880f}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{cce594b6-0c39-4442-ba28-10c64ac7e89f}"
"$type": "Document",
"DocumentIndex": 2,
"Title": "DynamicCodeCoverage.coveragexml",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\DynamicCodeCoverage.coveragexml",
"RelativeDocumentMoniker": "DynamicCodeCoverage.coveragexml",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\DynamicCodeCoverage.coveragexml",
"RelativeToolTip": "DynamicCodeCoverage.coveragexml",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002488|",
"WhenOpened": "2024-04-23T20:33:57.768Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "Chemistry Cafe API.csproj",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Chemistry Cafe API.csproj",
"RelativeDocumentMoniker": "Chemistry Cafe API.csproj",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Chemistry Cafe API.csproj",
"RelativeToolTip": "Chemistry Cafe API.csproj",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABsAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
"WhenOpened": "2024-04-23T20:27:01.181Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "test.coverage",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\test.coverage",
"RelativeDocumentMoniker": "test.coverage",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\test.coverage",
"RelativeToolTip": "test.coverage",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002488|",
"WhenOpened": "2024-04-23T20:27:15.659Z"
},
{
"$type": "Document",
"DocumentIndex": 7,
"Title": "Readme.txt",
"DocumentMoniker": "C:\\Users\\Evan\\.nuget\\packages\\reportgenerator\\5.2.5\\Readme.txt",
"RelativeDocumentMoniker": "..\\..\\..\\.nuget\\packages\\reportgenerator\\5.2.5\\Readme.txt",
"ToolTip": "C:\\Users\\Evan\\.nuget\\packages\\reportgenerator\\5.2.5\\Readme.txt",
"RelativeToolTip": "..\\..\\..\\.nuget\\packages\\reportgenerator\\5.2.5\\Readme.txt",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAYAAAAtAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003109|",
"WhenOpened": "2024-04-23T20:15:17.994Z"
},
{
"$type": "Document",
"DocumentIndex": 8,
"Title": "Evan_DESKTOP-J5QL00B_2024-04-23.15_06_43.coverage",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\TestResults\\bebeeb31-5fa4-4b64-b3ed-85c033f075be\\Evan_DESKTOP-J5QL00B_2024-04-23.15_06_43.coverage",
"RelativeDocumentMoniker": "TestResults\\bebeeb31-5fa4-4b64-b3ed-85c033f075be\\Evan_DESKTOP-J5QL00B_2024-04-23.15_06_43.coverage",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\TestResults\\bebeeb31-5fa4-4b64-b3ed-85c033f075be\\Evan_DESKTOP-J5QL00B_2024-04-23.15_06_43.coverage",
"RelativeToolTip": "TestResults\\bebeeb31-5fa4-4b64-b3ed-85c033f075be\\Evan_DESKTOP-J5QL00B_2024-04-23.15_06_43.coverage",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002488|",
"WhenOpened": "2024-04-23T20:06:56.242Z"
},
{
"$type": "Document",
"DocumentIndex": 9,
"Title": "OpenAtmosService.cs",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Services\\OpenAtmosService.cs",
"RelativeDocumentMoniker": "Services\\OpenAtmosService.cs",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Services\\OpenAtmosService.cs",
"RelativeToolTip": "Services\\OpenAtmosService.cs",
"ViewState": "AQIAAN0AAAAAAAAAAAAcwOIAAAAVAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-23T18:43:31.993Z"
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "appsettings.json",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\appsettings.json",
"RelativeDocumentMoniker": "appsettings.json",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\appsettings.json",
"RelativeToolTip": "appsettings.json",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAPAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
"WhenOpened": "2024-04-23T17:05:43.115Z"
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Program.cs",
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA8AAAAaAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-23T16:27:20.779Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Chemistry Cafe API.http",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Chemistry Cafe API.http",
"RelativeDocumentMoniker": "Chemistry Cafe API.http",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Chemistry Cafe API.http",
"RelativeToolTip": "Chemistry Cafe API.http",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAUAAAADAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003502|",
"WhenOpened": "2024-04-23T17:04:42.909Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 6,
"Title": "Chemistry Cafe API",
"DocumentMoniker": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Chemistry Cafe API.csproj",
"RelativeDocumentMoniker": "Chemistry Cafe API.csproj",
"ToolTip": "C:\\Users\\Evan\\Documents\\GitHub\\chemistry-cafe-api\\Chemistry Cafe API.csproj",
"RelativeToolTip": "Chemistry Cafe API.csproj",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
"WhenOpened": "2024-04-23T20:17:32.081Z",
"EditorCaption": ""
}
]
}
Expand Down
Binary file modified .vs/ProjectEvaluation/chemistry cafe api.metadata.v7.bin
Binary file not shown.
Binary file modified .vs/ProjectEvaluation/chemistry cafe api.projects.v7.bin
Binary file not shown.
7 changes: 7 additions & 0 deletions Chemistry Cafe API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
<UserSecretsId>5c953ed8-0279-4c49-a044-edbcddca45e1</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.4" />
<PackageReference Include="Microsoft.CodeCoverage" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="MySqlConnector" Version="2.3.5" />
<PackageReference Include="MySqlConnector.DependencyInjection" Version="2.3.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="xunit.extensibility.core" Version="2.7.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Chemistry Cafe API.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34616.47
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chemistry Cafe API", "Chemistry Cafe API.csproj", "{62738D41-607A-4727-AADD-D4B41BA734C9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chemistry Cafe API", "Chemistry Cafe API.csproj", "{62738D41-607A-4727-AADD-D4B41BA734C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
1 change: 1 addition & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
builder.Services.AddSwaggerGen();

//Adds SQL data source from appsettings.json file

builder.Services.AddMySqlDataSource(builder.Configuration.GetConnectionString("Default")!);


Expand Down
2 changes: 1 addition & 1 deletion Services/PropertyTypeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task UpdatePropertyTypeAsync(PropertyType propertyType)
using var connection = await database.OpenConnectionAsync();
using var command = connection.CreateCommand();

command.CommandText = @"UPDATE PropertyType SET name = @name, units = @units, validation = @validation, isDel = @isDel, WHERE uuid = @uuid;";
command.CommandText = @"UPDATE PropertyType SET name = @name, units = @units, validation = @validation, isDel = @isDel WHERE uuid = @uuid;";

command.Parameters.AddWithValue("@uuid", propertyType.uuid);
command.Parameters.AddWithValue("@name", propertyType.name);
Expand Down
4 changes: 2 additions & 2 deletions Services/PropertyVersionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public async Task UpdatePropertyVersionAsync(PropertyVersion propertyVersion)
using var connection = await database.OpenConnectionAsync();
using var command = connection.CreateCommand();

command.CommandText = @"UPDATE Property_Version SET family_uuid = @family_uuid, frozen_version = @frozen_version, tag_mechanism_uuid = @tag_mechanism_uuid,
command.CommandText = @"UPDATE Property_Version SET parent_property_uuid = @parent_property_uuid, frozen_version = @frozen_version, tag_mechanism_uuid = @tag_mechanism_uuid,
property_type = @property_type, float_value = @float_value, double_value = @double_value, int_value = @int_value, string_value = @string_value, action = @action,
user_uuid = @user_uuid, datetime = @datetime, isDel = @isDel WHERE uuid = @uuid;";

command.Parameters.AddWithValue("@uuid", propertyVersion.uuid);
command.Parameters.AddWithValue("@parent_property_uuid", propertyVersion.parent_property_uuid);
command.Parameters.AddWithValue("@frozen_version", propertyVersion.frozen_version);
command.Parameters.AddWithValue("@mechanism_uuid", propertyVersion.tag_mechanism_uuid);
command.Parameters.AddWithValue("@tag_mechanism_uuid", propertyVersion.tag_mechanism_uuid);
command.Parameters.AddWithValue("@property_type", propertyVersion.property_type);
command.Parameters.AddWithValue("@float_value", propertyVersion.float_value);
command.Parameters.AddWithValue("@double_value", propertyVersion.double_value);
Expand Down
4 changes: 2 additions & 2 deletions Services/TagMechanismReactionListService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ private async Task<IReadOnlyList<TagMechanismReactionList>> ReadAllAsync(DbDataR
var mechTag = new TagMechanismReactionList
{
uuid = reader.GetGuid(0),
reaction_uuid = reader.GetGuid(1),
tag_mechanism_uuid = reader.GetGuid(2),
tag_mechanism_uuid = reader.GetGuid(1),
reaction_uuid = reader.GetGuid(2),
version = reader.GetString(3),
isDel = reader.GetBoolean(4),
};
Expand Down
4 changes: 2 additions & 2 deletions Services/TagMechanismSpeciesListService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ private async Task<IReadOnlyList<TagMechanismSpeciesList>> ReadAllAsync(DbDataRe
var mechTag = new TagMechanismSpeciesList
{
uuid = reader.GetGuid(0),
species_uuid = reader.GetGuid(1),
tag_mechanism_uuid = reader.GetGuid(2),
tag_mechanism_uuid = reader.GetGuid(1),
species_uuid = reader.GetGuid(2),
version = reader.GetString(3),
isDel = reader.GetBoolean(4),
};
Expand Down
9 changes: 9 additions & 0 deletions Tests/DBConnection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using MySqlConnector;

namespace Chemistry_Cafe_API.Tests
{
public class DBConnection
{
public static MySqlDataSource DataSource = new MySqlDataSource("Server=chemisty-cafe.cl8uuceq2rud.us-east-1.rds.amazonaws.com;User ID=cafeadmin;Password=cafeadmin;Port=3306;Database=Testing");
}
}
50 changes: 50 additions & 0 deletions Tests/FamilyControllerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Chemistry_Cafe_API.Controllers;
using Chemistry_Cafe_API.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MySqlConnector;

namespace Chemistry_Cafe_API.Tests
{
[TestClass]
public class FamilyControllerTests
{
FamilyController controller = new FamilyController(DBConnection.DataSource);

[TestMethod]
public async Task Get_retrieves_family()
{

var result = await controller.Get() as List<Family>;

Assert.IsNotNull(result);
}

[TestMethod]
public async Task Creates_family()
{

var result = await controller.Create("Test") ;

var getResult = await controller.Get(result.uuid);

Assert.AreEqual(result.uuid, getResult.uuid);
}

[TestMethod]
public async Task Updates_family()
{

var result = await controller.Create("Test");

result.name = "Edited";

await controller.Put(result);

var getResult = await controller.Get(result.uuid);

await controller.Delete(result.uuid);

Assert.AreEqual(result.name, "Edited");
}
}
}
Loading

0 comments on commit 85b3eaa

Please sign in to comment.