Exemple #1
0
        public void DestroyCopyTest()
        {
            repo        = new DataRepository(new ContextFiller());
            dataService = new DataService(repo);

            DateTimeOffset testDate = new DateTimeOffset(2019, 10, 19, 22, 0, 0, new TimeSpan(2, 0, 0));

            bool DestructionEventRised = false;

            dataService.DestructionHappened += DestructionEventMethod;
            void DestructionEventMethod(object sender, EventArgs e)
            {
                if (DestructionEventRised == true)
                {
                    Assert.Fail("Event rised multiple times");
                }
                else
                {
                    DestructionEventRised = true;
                }
            }

            Assert.AreEqual(true, repo.ContainsCopy(1));

            dataService.DestroyCopy(1, testDate, "TestReason");
            DestructionEvent destructionEvent = (DestructionEvent)repo.GetAllEvents().Last();

            Assert.AreEqual(false, repo.ContainsCopy(1));

            Assert.AreEqual(true, DestructionEventRised);

            Assert.AreEqual("TestReason", destructionEvent.Reason);
            Assert.AreEqual(1, destructionEvent.Copy.CopyId);
        }
Exemple #2
0
        public void HitBoat()
        {
            Hits++;

            if (Hits == Length)
            {
                IsDestroyed = true;
                DestructionEvent?.Invoke(Id);
            }
        }