used mongodb as database
This commit is contained in:
1 parent
e18931b6c0
commit
a5ed2d866e
13 files changed
+94
-139
No files matched your search
@@ -20,4 +20,8 @@
|
||||
<ProjectReference Include="..\RobotsWantedLeague\RobotsWantedLeague.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,25 +0,0 @@
|
||||
namespace RobotsWantedLeague.Test.Services;
|
||||
using RobotsWantedLeague.Models;
|
||||
using RobotsWantedLeague.Services;
|
||||
|
||||
[TestClass]
|
||||
public class NotEmptyRobotsServiceTest
|
||||
{
|
||||
|
||||
[TestMethod]
|
||||
public void TestHappyPath()
|
||||
{
|
||||
IRobotsService service = new NotEmptyRobotsService();
|
||||
Assert.AreEqual(3, service.Robots.Count);
|
||||
Robot robot = service.CreateRobot("paul", 2, 3, "canada");
|
||||
Assert.AreEqual(robot.Name, "paul");
|
||||
Assert.AreEqual(robot.Weight, 2);
|
||||
|
||||
Assert.AreEqual(4, service.Robots.Count);
|
||||
|
||||
service.DeleteRobotById(robot.Id);
|
||||
Assert.AreEqual(3, service.Robots.Count);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
namespace RobotsWantedLeague.Test.Services;
|
||||
using RobotsWantedLeague.Models;
|
||||
using RobotsWantedLeague.Services;
|
||||
|
||||
[TestClass]
|
||||
public class RobotsServiceTest
|
||||
{
|
||||
|
||||
[TestMethod]
|
||||
public void TestCreateRobot()
|
||||
{
|
||||
RobotsService service = new RobotsService();
|
||||
Robot robot = service.CreateRobot("paul", 2, 3, "canada");
|
||||
Assert.AreEqual(robot.Name, "paul");
|
||||
Assert.AreEqual(robot.Weight, 2);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetRobotById()
|
||||
{
|
||||
RobotsService service = new RobotsService();
|
||||
Assert.IsNull(service.GetRobotById(98));
|
||||
Robot robot = service.CreateRobot("paul", 2, 3, "canada");
|
||||
Robot? ret = service.GetRobotById(robot.Id);
|
||||
Assert.IsNotNull(ret);
|
||||
Assert.AreEqual(robot.Name, ret.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetRobotById_MultipleRobots()
|
||||
{
|
||||
RobotsService service = new RobotsService();
|
||||
Robot robot1 = service.CreateRobot("paul", 2, 3, "canada");
|
||||
Robot robot2 = service.CreateRobot("emanuel", 20, 30, "france");
|
||||
Robot? ret = service.GetRobotById(robot2.Id);
|
||||
Assert.IsNotNull(ret);
|
||||
Assert.AreEqual(robot2.Name, ret.Name);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestListRobots()
|
||||
{
|
||||
RobotsService service = new RobotsService();
|
||||
Robot robot1 = service.CreateRobot("paul", 2, 3, "canada");
|
||||
Robot robot2 = service.CreateRobot("emanuel", 20, 30, "france");
|
||||
Assert.AreEqual(2, service.Robots.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestDeleteRobotById()
|
||||
{
|
||||
RobotsService service = new RobotsService();
|
||||
Robot robot1 = service.CreateRobot("paul", 2, 3, "canada");
|
||||
Robot robot2 = service.CreateRobot("emanuel", 20, 30, "france");
|
||||
Robot robot3 = service.CreateRobot("xu", 1, 9, "chine");
|
||||
|
||||
Assert.IsTrue(service.DeleteRobotById(robot2.Id));
|
||||
|
||||
Assert.AreEqual(2, service.Robots.Count);
|
||||
Assert.IsNull(service.GetRobotById(robot2.Id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user