Beispiel #1
0
        public async Task ModifyDiveLogEntryFailsWithNullLocation()
        {
            // --- Arrange
            var service = HttpServiceFactory.CreateService <IDiveLogService>();
            var dive    = new DiveLogEntryDto
            {
                Date       = new DateTime(2008, 6, 7),
                DiveSite   = "Gotta Abu Ramada",
                Location   = null,
                MaxDepth   = 22.6M,
                BottomTime = 54
            };

            // --- Act
            try
            {
                await service.ModifyDiveLogEntryAsync(dive);
            }
            catch (ArgumentValidationException ex)
            {
                ex.Notifications.Items.ShouldHaveCountOf(1);
                ex.Notifications.Items[0].Target.ShouldEqual("dive.Location");
                ex.Notifications.Items[0].Code.ShouldEqual(ValidationCodes.NULL_NOT_ALLOWED);
                return;
            }
            Assert.Fail("ArgumentValidationException expected.");
        }
Beispiel #2
0
        public async Task ModifyDiveLogEntryFailsWithTooHighBottomTime()
        {
            // --- Arrange
            var service = HttpServiceFactory.CreateService <IDiveLogService>();
            var dive    = new DiveLogEntryDto
            {
                Date       = new DateTime(2008, 6, 7),
                DiveSite   = "Gotta Abu Ramada",
                Location   = "Hurghada, Egypt",
                MaxDepth   = 22.6M,
                BottomTime = 481
            };

            // --- Act
            try
            {
                await service.ModifyDiveLogEntryAsync(dive);
            }
            catch (ArgumentValidationException ex)
            {
                ex.Notifications.Items.ShouldHaveCountOf(1);
                ex.Notifications.Items[0].Target.ShouldEqual("dive.BottomTime");
                ex.Notifications.Items[0].Code.ShouldEqual(ValidationCodes.OUT_OF_RANGE);
                return;
            }
            Assert.Fail("ArgumentValidationException expected.");
        }
Beispiel #3
0
        public async Task RemoveDiveLogEntryWorksAsExpected()
        {
            // --- Arrange
            var service = HttpServiceFactory.CreateService <IDiveLogService>();
            var dive    = new DiveLogEntryDto
            {
                Date       = new DateTime(2008, 6, 7),
                DiveSite   = "Gotta Abu Ramada",
                Location   = "Hurghada, Egypt",
                MaxDepth   = 22.6M,
                BottomTime = 54,
                Comment    = "It was a great dive"
            };
            var id = await service.RegisterDiveLogEntryAsync(dive);

            // --- Act
            var diveBack1 = await service.GetDiveByIdAsync(id);

            await service.RemoveDiveLogEntryAsync(id);

            var notFound = false;

            try
            {
                await service.GetDiveByIdAsync(id);
            }
            catch (DiveNotFoundException)
            {
                notFound = true;
            }

            // --- Assert
            diveBack1.ShouldNotBeNull();
            notFound.ShouldBeTrue();
        }
Beispiel #4
0
        public async Task RegisterDiveLogEntryFailsWithPresetId()
        {
            // --- Arrange
            var service = HttpServiceFactory.CreateService <IDiveLogService>();
            var dive    = new DiveLogEntryDto
            {
                Id         = 123,
                Date       = new DateTime(2008, 6, 7),
                DiveSite   = "Gotta Abu Ramada",
                Location   = "Hurghada, Egypt",
                MaxDepth   = 22.6M,
                BottomTime = 54
            };

            // --- Act
            try
            {
                await service.RegisterDiveLogEntryAsync(dive);
            }
            catch (ArgumentValidationException ex)
            {
                ex.Notifications.Items.ShouldHaveCountOf(1);
                ex.Notifications.Items[0].Target.ShouldEqual("dive.Id");
                ex.Notifications.Items[0].Code.ShouldEqual(ValidationCodes.VALIDATION_FAILS);
                return;
            }
            Assert.Fail("ArgumentValidationException expected.");
        }
Beispiel #5
0
        public async Task ModifyDiveLogEntryWorksAsExpected()
        {
            // --- Arrange
            var service = HttpServiceFactory.CreateService <IDiveLogService>();
            var dive    = new DiveLogEntryDto
            {
                Date       = new DateTime(2008, 6, 7),
                DiveSite   = "Gotta Abu Ramada",
                Location   = "Hurghada, Egypt",
                MaxDepth   = 22.6M,
                BottomTime = 54,
                Comment    = "It was a great dive"
            };
            var id = await service.RegisterDiveLogEntryAsync(dive);

            // --- Act
            dive.Id         = id;
            dive.BottomTime = 102;
            dive.Comment    = "It was a long dive";
            await service.ModifyDiveLogEntryAsync(dive);

            // --- Assert
            var diveback = await service.GetDiveByIdAsync(id);

            diveback.Id.ShouldBeGreaterThan(0);
            diveback.Date.ShouldEqual(dive.Date);
            diveback.DiveSite.ShouldEqual(dive.DiveSite);
            diveback.Location.ShouldEqual(dive.Location);
            diveback.MaxDepth.ShouldEqual(dive.MaxDepth);
            diveback.BottomTime.ShouldEqual(dive.BottomTime);
            diveback.Comment.ShouldEqual(dive.Comment);
        }
        public async Task <List <UserInvitationCoreDto> > GetInvitedUsers()
        {
            var srvObj = HttpServiceFactory.CreateService <ISubscriptionService>();
            var result = await srvObj.GetInvitedUsersAsync();

            return(result);
        }
Beispiel #7
0
        public async Task RemoveDiveLogEntryFailsWithUnknownDive()
        {
            // --- Arrange
            var service = HttpServiceFactory.CreateService <IDiveLogService>();

            // --- Act
            await service.RemoveDiveLogEntryAsync(-1);
        }
Beispiel #8
0
        public async Task GetDiveByIdFailsWithNonExistingId()
        {
            // --- Arrange
            const int NON_EXISTING_DIVE_ID = -1;
            var       service = HttpServiceFactory.CreateService <IDiveLogService>();

            // --- Act
            await service.GetDiveByIdAsync(NON_EXISTING_DIVE_ID);
        }
Beispiel #9
0
        public async Task RemoveDiveLogEntryFailsWithAnotherUser()
        {
            // --- Arrange
            const int ANOTHER_USERS_DIVE_ID = 10;
            var       service = HttpServiceFactory.CreateService <IDiveLogService>();

            // --- Act
            await service.RemoveDiveLogEntryAsync(ANOTHER_USERS_DIVE_ID);
        }
Beispiel #10
0
        public async Task GetAllDivesForUserWorksAsExpected()
        {
            // --- Arrange
            const int DIVES_IN_INIT_SCRIPT_FOR_TEST_USER = 9;
            var       service = HttpServiceFactory.CreateService <IDiveLogService>();

            // --- Act
            var dives = await service.GetAllDivesOfUserAsync();

            // --- Assert
            dives.ShouldHaveCountOf(DIVES_IN_INIT_SCRIPT_FOR_TEST_USER);
        }
Beispiel #11
0
        public async Task GetDiveByIdWorksAsExpected()
        {
            // --- Arrange
            const int EXISTING_DIVE_ID = 1;
            var       service          = HttpServiceFactory.CreateService <IDiveLogService>();

            // --- Act
            var existingDive = await service.GetDiveByIdAsync(EXISTING_DIVE_ID);

            // --- Assert
            existingDive.ShouldNotBeNull();
        }
Beispiel #12
0
        public async Task ModifyDiveLogEntryFailsWithUnknownDive()
        {
            // --- Arrange
            var service = HttpServiceFactory.CreateService <IDiveLogService>();
            var dive    = new DiveLogEntryDto
            {
                Id         = -1,
                Date       = new DateTime(2008, 6, 7),
                DiveSite   = "Gotta Abu Ramada",
                Location   = "Hurghada, Egypt",
                MaxDepth   = 22.6M,
                BottomTime = 54,
                Comment    = "It was a great dive"
            };

            // --- Act
            await service.ModifyDiveLogEntryAsync(dive);
        }
Beispiel #13
0
        public async Task RegisterDiveLogEntryFailsWithNullRequest()
        {
            // --- Arrange
            var service = HttpServiceFactory.CreateService <IDiveLogService>();

            // --- Act
            try
            {
                await service.RegisterDiveLogEntryAsync(null);
            }
            catch (ArgumentValidationException ex)
            {
                ex.Notifications.Items.ShouldHaveCountOf(1);
                ex.Notifications.Items[0].Target.ShouldEqual("dive");
                ex.Notifications.Items[0].Code.ShouldEqual(ValidationCodes.NULL_NOT_ALLOWED);
                return;
            }
            Assert.Fail("ArgumentValidationException expected.");
        }
Beispiel #14
0
        public async Task ModifyDiveLogEntryFailsWithAnotherUser()
        {
            // --- Arrange
            const int ANOTHER_USERS_DIVE_ID = 10;
            var       service = HttpServiceFactory.CreateService <IDiveLogService>();
            var       dive    = new DiveLogEntryDto
            {
                Id         = ANOTHER_USERS_DIVE_ID,
                Date       = new DateTime(2008, 6, 7),
                DiveSite   = "Gotta Abu Ramada",
                Location   = "Hurghada, Egypt",
                MaxDepth   = 22.6M,
                BottomTime = 54,
                Comment    = "It was a great dive"
            };

            // --- Act
            await service.ModifyDiveLogEntryAsync(dive);
        }
Beispiel #15
0
 public async Task RemoveDiveLogEntryAsync(int diveId)
 {
     var srvObj = HttpServiceFactory.CreateService <IDiveLogService>();
     await srvObj.RemoveDiveLogEntryAsync(diveId);
 }
Beispiel #16
0
 public async Task ModifyDiveLogEntryAsync(DiveLogEntryDto dive)
 {
     var srvObj = HttpServiceFactory.CreateService <IDiveLogService>();
     await srvObj.ModifyDiveLogEntryAsync(dive);
 }
Beispiel #17
0
        public async Task <int> RegisterDiveLogEntryAsync(DiveLogEntryDto dive)
        {
            var srvObj = HttpServiceFactory.CreateService <IDiveLogService>();

            return(await srvObj.RegisterDiveLogEntryAsync(dive));
        }
Beispiel #18
0
        public async Task <DiveLogEntryDto> GetDiveByIdAsync(int diveId)
        {
            var srvObj = HttpServiceFactory.CreateService <IDiveLogService>();

            return(await srvObj.GetDiveByIdAsync(diveId));
        }
Beispiel #19
0
        public async Task <List <DiveLogEntryDto> > GetAllDivesOfUserAsync()
        {
            var srvObj = HttpServiceFactory.CreateService <IDiveLogService>();

            return(await srvObj.GetAllDivesOfUserAsync());
        }
 public async Task InviteUserAsync(InviteUserDto userInfo)
 {
     var srvObj = HttpServiceFactory.CreateService <ISubscriptionService>();
     await srvObj.InviteUserAsync(userInfo);
 }