From a2e046634031245f6734a1294270591bd033c27f Mon Sep 17 00:00:00 2001 From: dicky Date: Mon, 29 Jun 2020 18:27:30 -0700 Subject: [PATCH] Fix unit test. --- UnitTests/ExampleSimpleListTest.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/UnitTests/ExampleSimpleListTest.cs b/UnitTests/ExampleSimpleListTest.cs index 7529a353..51942cd0 100644 --- a/UnitTests/ExampleSimpleListTest.cs +++ b/UnitTests/ExampleSimpleListTest.cs @@ -62,6 +62,28 @@ public ExampleSimpleListTest() await Task.Delay(10); _mockData.Remove(_mockData.First(x => x.Id == id)); }) + .Setup(x => x.GetAll(It.IsAny())).Returns(() => + { + return _mockData.AsEnumerable(); + }) + .Setup(x => x.Get(It.IsAny())).Returns((int id) => + { + return _mockData.FirstOrDefault(x => x.Id == id); + }) + .Setup(x => x.Add(It.IsAny())).Returns(() => + { + return 3; + }) + .Setup(x => x.Update(It.IsAny())).Calls((Employee update) => + { + var data = _mockData.First(x => x.Id == update.Id); + data.FirstName = update.FirstName; + data.LastName = update.LastName; + }) + .Setup(x => x.Remove(It.IsAny())).Calls((int id) => + { + _mockData.Remove(_mockData.First(x => x.Id == id)); + }) .Object; _hubEmulator = new HubEmulatorBuilder()