public void CallController_CreateNewCall_ReturnsActionResultWithCallIdInDescription() { Mock<ICallRepository> mock = new Mock<ICallRepository>(); var CUT = new CallController(mock.Object); var patient = new Patient() { _id = ObjectId.GenerateNewId().ToString(), ImportantInfo = "Denne skal ikke bruges alligevel :<", PatientCPR = "654321-4321", PatientName = "PATester" }; var newCall = new CreateCallModel() { PatientCPR = "654321-4321", Category = "TestCategory", Choice = "TestChoice", CreatedOn = DateTime.Now.ToString("F"), Detail = "TestDetail" }; var callId = CUT.CreateCall(newCall); Assert.IsNotNull(callId); }
/// <summary> /// Add Patient to Datamock /// </summary> /// <param name="patient"></param> /// <returns></returns> public string Add(Patient patient) { try { _log.Debug("Adding new Patient to datamock"); _patients.InsertOneAsync(patient.ToBsonDocument()).Wait(); return patient._id; } catch (Exception ex) { _log.Exception(ex.Message + ex.InnerException); throw; } }
/// <summary> /// Update patient in datamock /// </summary> /// <param name="patient"></param> /// <returns></returns> public UpdateResult Update(Patient patient) { try { var filter = Builders<BsonDocument>.Filter.Eq("_id", patient._id); var update = Builders<BsonDocument>.Update.Set("PatientCPR", patient.PatientCPR) .Set("PatientName", patient.PatientName) .Set("ImportantInfo", patient.ImportantInfo); return _patients.UpdateOneAsync(filter, update).Result; } catch (Exception ex) { _log.Exception(ex.Message + ex.InnerException); throw; } }