public void TopSecretSplitFullTestOK() { var options = new DbContextOptionsBuilder <TopSecretSplitContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .EnableSensitiveDataLogging() .Options; var context = new TopSecretSplitContext(options); TopSecretSplitController topSecretSplitController = new TopSecretSplitController(context); string parameter1 = "{\"distance\": 583.0,\"message\": [\"este\", \"\", \"\", \"mensaje\", \"\"]}"; string parameter2 = "{\"distance\": 223,\"message\": [\"\", \"es\", \"\", \"\", \"secreto\"]}"; string parameter3 = "{\"distance\": 500,\"message\": [\"este\", \"\", \"un\", \"\", \"\"]}"; topSecretSplitController.PostTopSecretSplit("kenobi", parameter1); topSecretSplitController.PostTopSecretSplit("skywalker", parameter2); topSecretSplitController.PostTopSecretSplit("sato", parameter3); ActionResult <string> GetResponse = topSecretSplitController.GetTopSecretSplitAll(); string result = GetResponse.Value; //TopSecretSplitItem topSecretSplitItem1 = JsonConvert.DeserializeObject<TopSecretSplitItem>(result); string spectedResult = "{\"position\":{\"x\":0.4,\"y\":98.6},\"message\":\"este es un mensaje secreto\"}"; Assert.AreEqual(spectedResult, result); Assert.Pass(); }
public void DbTestOK() { var options = new DbContextOptionsBuilder <TopSecretSplitContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .EnableSensitiveDataLogging() .Options; var context = new TopSecretSplitContext(options); TopSecretSplitController topSecretSplitController = new TopSecretSplitController(context); string parameter = "{\"distance\": 583.0,\"message\": [\"este\", \"\", \"un\", \"\", \"\"]}"; topSecretSplitController.PostTopSecretSplit("kenobi", parameter); ActionResult <string> GetResponse = topSecretSplitController.GetTopSecretSplit("kenobi"); string result = GetResponse.Value; //TopSecretSplitItem topSecretSplitItem1 = JsonConvert.DeserializeObject<TopSecretSplitItem>(result); string spectedResult = "{\"name\":\"kenobi\",\"distance\":583.0,\"message\":[\"este\",\"\",\"un\",\"\",\"\"]}"; Assert.AreEqual(spectedResult, result); Assert.Pass(); }
public void TopSecretSplitFullTestNotEnoughSatellitesInfoFail() { var options = new DbContextOptionsBuilder <TopSecretSplitContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .EnableSensitiveDataLogging() .Options; var context = new TopSecretSplitContext(options); TopSecretSplitController topSecretSplitController = new TopSecretSplitController(context); string parameter1 = "{\"distance\": 583.0,\"message\": [\"este\", \"\", \"\", \"\", \"\"]}"; topSecretSplitController.PostTopSecretSplit("kenobi", parameter1); string spectedResult = ""; string result = ""; ActionResult <string> GetResponse = topSecretSplitController.GetTopSecretSplitAll(); Assert.AreEqual(HttpStatusCode.NotFound, GetResponse.Result); Assert.Pass(); }
public TopSecretSplitController(TopSecretSplitContext context) { //TODO: here I can implement a dynamic interface creator which would depend on the type of db and dbContext. _dbTopSecretSplitController = new DbTopSecretSplitController(context); }
public DbTopSecretSplitController(TopSecretSplitContext context) { _context = (TopSecretSplitContext)context; //Receive here the database Context to be manage in this class. }