Beispiel #1
0
        public void Map_MapFromBarRepToBarRepDto_CorrectType()
        {
            var barRep    = new BarRepresentative();
            var barRepDto = uut.Map <BarRepresentativeDto>(barRep);

            Assert.That(barRepDto, Is.TypeOf <BarRepresentativeDto>());
        }
Beispiel #2
0
        public void BarRepRepo_WithoutBarName_ThrowsAnException()
        {
            var barRep = new BarRepresentative()
            {
                Username = "******",
                Name     = "TestName",
                //BarName = "Katrines Kælder"
            };

            Assert.That(() => _uut.Add(barRep), Throws.Exception);
        }
Beispiel #3
0
        public void Setup()
        {
            mockUnitOfWork = Substitute.For <IUnitOfWork>();

            var profile       = new MappingProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(profile));

            mapper = new Mapper(configuration);

            uut = new BarRepresentativeController(mockUnitOfWork, mapper);

            defaultList = new List <BarRepresentative>()
            {
                new BarRepresentative()
                {
                    BarName  = "TestBar",
                    Name     = "Navn1",
                    Username = "******",
                    Bar      = null,
                },
                new BarRepresentative()
                {
                    BarName  = "TestBar2",
                    Name     = "Navn2",
                    Username = "******",
                    Bar      = null,
                }
            };
            defaultBarRep = defaultList[0];

            // Direct conversion without navigational property
            correctResultList = new List <BarRepresentativeDto>()
            {
                new BarRepresentativeDto()
                {
                    BarName  = "TestBar",
                    Name     = "Navn1",
                    Username = "******",
                },
                new BarRepresentativeDto()
                {
                    BarName  = "TestBar2",
                    Name     = "Navn2",
                    Username = "******",
                }
            };
            defaultBarRepDto = correctResultList[0];
        }
Beispiel #4
0
        /// <summary>
        /// Logic that defines the behaviour for the Login command.
        /// This uses the _apiService to LoginAsync with a LoginDTO, it also displays an error if something goes wrong and updates the Customer object if login is successful
        /// </summary>
        private async void OnLoginCommand()
        {
            User customer = User.GetCustomer();

            if (!customer.LoggedIn)
            {
                LoginDTO dto = new LoginDTO()
                {
                    Username = Username,
                    Password = Password,
                };
                try
                {
                    string token = await RestClient.LoginAsync(dto);

                    if (token != null)
                    {
                        customer.UserToken = token;
                        customer.UserName  = Username;

                        Application.Current.Properties["Token"]    = customer.UserToken;
                        Application.Current.Properties["Username"] = customer.UserName;

                        BarRepresentative barrep = await RestClient.GetSpecificBarRepresentative(customer.UserName);

                        if (barrep.Name != null)
                        {
                            customer.FavoriteBar = barrep.BarName;
                            customer.IsBarRep    = true;
                        }

                        await NavigationService.GoBackAsync();
                    }
                    else
                    {
                        await Alerter.Alert("Error",
                                            "Something went wrong in the login!", "OK");
                    }
                }
                catch (Exception e)
                {
                    await Alerter.Alert("Error",
                                        e.Message, "OK");
                }
            }
        }
Beispiel #5
0
        public void Edit_Entity_WithoutChangingAnyInformation()
        {
            _uut.Add(new BarRepresentative()
            {
                Username = "******",
                Name     = "TestName",
                BarName  = "Katrines Kælder"
            });
            _context.SaveChanges();

            BarRepresentative newRep = new BarRepresentative()
            {
                Username = "******",
                Name     = "TestName",
            };

            _uut.Edit(newRep);
            _context.SaveChanges();

            Assert.AreEqual("TestName", _uut.Get("TestUsername").Name);
        }
Beispiel #6
0
        public void Constraint_OnUsername_ThrowsAnException()
        {
            var _barRep = new BarRepresentative()
            {
                Username = "******",
                Name     = "TestName",
                BarName  = "Katrines Kælder"
            };

            _uut.Add(_barRep);
            _context.SaveChanges();

            var _barRep2 = new BarRepresentative()
            {
                Username = "******",
                Name     = "TestName2",
                BarName  = "Katrines Kælder",
            };

            Assert.That(() => _uut.Add(_barRep2), Throws.Exception);
        }
Beispiel #7
0
        public void Add_Several_Representatives()
        {
            var _barRep = new BarRepresentative()
            {
                Username = "******",
                Name     = "TestName",
                BarName  = "Katrines Kælder"
            };

            _uut.Add(_barRep);


            var _barRep2 = new BarRepresentative()
            {
                Username = "******",
                Name     = "TestName2",
                BarName  = "Katrines Kælder"
            };

            _uut.Add(_barRep2);


            Assert.AreEqual(2, _context.SaveChanges());
        }
        public void Setup()
        {
            _bar1 = new Bar()
            {
                Address          = "FakeAddress",
                AgeLimit         = 18,
                AvgRating        = 0,
                BarName          = "FakeBar",
                CVR              = 12345678,
                Educations       = "FakeEdu",
                Email            = "*****@*****.**",
                Image            = "FakeImg",
                PhoneNumber      = 88888888,
                ShortDescription = "Fake Short Desc",
                LongDescription  = "Fake Long Desc",
            };
            _bar2 = new Bar()
            {
                Address          = "FakeAddress2",
                AgeLimit         = 21,
                AvgRating        = 4,
                BarName          = "FakeBar2",
                CVR              = 12345679,
                Educations       = "FakeEdu2",
                Email            = "*****@*****.**",
                Image            = "FakeImg2",
                PhoneNumber      = 88888889,
                ShortDescription = "Fake Short Desc2",
                LongDescription  = "Fake Long Desc2",
            };

            _drink1 = new Drink()
            {
                BarName    = "Katrines Kælder",
                DrinksName = "Fadoel",
                Price      = 20,
            };

            _review1 = new Review()
            {
                BarName     = "FakeBar",
                BarPressure = 5,
                Username    = "******",
            };

            _review2 = new Review()
            {
                BarName     = "FakeBar",
                BarPressure = 3,
                Username    = "******",
            };

            _barEvent = new BarEvent()
            {
                BarName   = "Katrines Kælder",
                Date      = new DateTime(2019, 5, 29),
                EventName = "FakeEvent",
            };

            _barRepresentative = new BarRepresentative()
            {
                BarName  = "Katrines Kælder",
                Name     = "FakeBarRepresentative",
                Username = "******",
            };

            _coupon = new Coupon()
            {
                BarName        = "Katrines Kælder",
                CouponID       = "FakeCouponID",
                ExpirationDate = new DateTime(2019, 12, 12),
            };

            _customer = new Customer()
            {
                DateOfBirth   = new DateTime(1997, 2, 5),
                Email         = "*****@*****.**",
                FavoriteDrink = "Beer",
                FavoriteBar   = "Katrines Kælder",
                Name          = "Andreas Vorgaard",
            };
            _connection = new SqliteConnection("Datasource=:memory:");
            _connection.Open();
            _options =
                new DbContextOptionsBuilder <BarOMeterContext>().UseSqlite(_connection).Options;
            _uut = new UnitOfWork(_options);
        }
Beispiel #9
0
 //POST api/barrepresentatives
 public async Task <bool> CreateBarRepresentative(BarRepresentative newBarRepresentative)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
 //PUT api/barrepresentatives
 public async Task <bool> EditBarRepresentative(BarRepresentative editedBarRepresentative)
 {
     throw new NotImplementedException();
 }