Exemple #1
0
        public async Task TestUpdate()
        {
            try
            {
                Election election = new Election()
                {
                    Date           = new DateTime(2022, 11, 3).Date,
                    StartDateLocal = new DateTime(2022, 11, 1, 8, 0, 0),
                    EndDateLocal   = new DateTime(2022, 11, 3, 20, 0, 0),
                    Description    = "2022 November Election",
                    Version        = "0.0.0.0",
                    AllowUpdates   = false
                };
                UOW.BeginTransaction();
                Election inserted = await electionService.Insert(UOW, election);

                Assert.IsNotNull(inserted);
                Assert.IsTrue(inserted.Id != Guid.Empty, "Expect inserted Election Id not be empty");
                inserted.Date           = new DateTime(2023, 11, 3).Date;
                inserted.StartDateLocal = new DateTime(2023, 11, 1, 8, 0, 0);
                inserted.EndDateLocal   = new DateTime(2023, 11, 3, 20, 0, 0);
                inserted.Description    = "2023 November Election";
                inserted.AllowUpdates   = true;
                Election updated = await electionService.Update(UOW, inserted);

                UOW.CloseTransaction();
                Assert.IsNotNull(updated, "Expected election to be updated");
                Assert.IsTrue(updated.Date.Year == 2023, "Expected election year to be 2023");
                Assert.IsTrue(updated.StartDateLocal.Year == 2023, "Expected election year to be 2023");
                Assert.IsTrue(updated.EndDateLocal.Year == 2023, "Expected election year to be 2023");
                Assert.IsTrue(updated.Description == "2023 November Election", "Expected desription to be updated");
                Assert.IsTrue(updated.AllowUpdates, "Expected allowUpdates to be true");
            }
            catch (Exception ex)
            {
                Assert.IsNull(ex, "Exception Thrown: " + ex.Message);
            }
        }