diff options
author | marcinzelent <marcin@zelent.net> | 2017-02-19 18:30:45 +0100 |
---|---|---|
committer | marcinzelent <marcin@zelent.net> | 2017-02-19 18:30:45 +0100 |
commit | 429a85c7a8a9a6372c5254dca7f4268e4889af28 (patch) | |
tree | 293bb94a0e0f119f392c78e472bc1dadf08787cb | |
parent | 03916a05140c9a60f2b225329dd70cf3e6ec8673 (diff) |
Added unit tests for adding, removing and editing events.
-rw-r--r-- | EventMaker/UnitTests/UnitTest.cs | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/EventMaker/UnitTests/UnitTest.cs b/EventMaker/UnitTests/UnitTest.cs index 0939520..d8481ae 100644 --- a/EventMaker/UnitTests/UnitTest.cs +++ b/EventMaker/UnitTests/UnitTest.cs @@ -1,18 +1,46 @@ using System; +using System.Collections.ObjectModel; using Windows.UI.Popups; using EventMaker.Model; +using EventMaker.ViewModel; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; namespace UnitTests { [TestClass] - public class UnitTest1 + public class UnitTest { [TestMethod] public void AddingTestMethod() { EventCatalogSingleton eventCatalogSingleton = EventCatalogSingleton.Instance; - EventCatalogSingleton.Instance.Add(new Event() { Id = 1, Name = "Party", Description = "Best party ever!", Place = "Roskilde" }); + eventCatalogSingleton.Events=new ObservableCollection<Event>(); + eventCatalogSingleton.Add(new Event()); + Assert.AreEqual(1, eventCatalogSingleton.Events.Count); } + + [TestMethod] + public void RemovingTestMethod() + { + EventCatalogSingleton eventCatalogSingleton = EventCatalogSingleton.Instance; + eventCatalogSingleton.Events = new ObservableCollection<Event>(); + eventCatalogSingleton.Add(new Event()); + Assert.AreEqual(1,eventCatalogSingleton.Events.Count); + eventCatalogSingleton.Remove(0); + Assert.AreEqual(0,eventCatalogSingleton.Events.Count); + } + + [TestMethod] + public void EditTestMethod() + { + EventCatalogSingleton eventCatalogSingleton = EventCatalogSingleton.Instance; + eventCatalogSingleton.Events = new ObservableCollection<Event>(); + eventCatalogSingleton.Add(new Event() {Id=0}); + Assert.AreEqual(1, eventCatalogSingleton.Events.Count); + Assert.AreEqual(0,eventCatalogSingleton.Events[0].Id); + eventCatalogSingleton.Update(0,new Event() {Id=1}); + Assert.AreEqual(1,eventCatalogSingleton.Events[0].Id); + } + } } |