public void TestCanViewSpecimen()
        {
            var specimens        = FakeSpecimens.Get().AsQueryable <Specimen>();
            var visibleSpecimens = specimens.CanViewContent(FakeUsers.GetPublic().AsModel());

            visibleSpecimens.Should().HaveCount(2);
        }
Beispiel #2
0
        public void TestAsSearchModel()
        {
            var specimens      = FakeSpecimens.Get();
            var specimenModels = specimens.Select(s => s.AsSearchModel());

            var firstSpecimen = specimenModels.First();

            firstSpecimen.Name.Should().Be("Liatris spicata seeds");
            firstSpecimen.Quantity.Should().Be(25);
            firstSpecimen.SpecimenStage.Should().Be(SpecimenStage.Seed);
            firstSpecimen.Lifeform.ScientificName.Should().Be("Liatris spicata");
            firstSpecimen.DateCreated.Should().NotBeNull();
            firstSpecimen.DateModified.Should().BeAfter(firstSpecimen.DateCreated.Value);
            firstSpecimen.Notes.Contains("feather").Should().BeTrue();
            firstSpecimen.ParentSpecimen.Should().BeNull();
            firstSpecimen.CreatedBy.Should().Be(Helpers.UserId);
            firstSpecimen.ModifiedBy.Should().Be(null);
            firstSpecimen.InventoryItem.Name.Should().Be("Liatris spicata seeds");
            firstSpecimen.InventoryItem.Inventory.Id.Should().Be(1);
            firstSpecimen.InventoryItem.Origin.Id.Should().Be(2);
            firstSpecimen.InventoryItem.ItemType.Should().Be(ItemType.Specimen);
            firstSpecimen.InventoryItem.Quantity.Should().Be(25);
            firstSpecimen.InventoryItem.Status.Should().Be(ItemStatus.Available);
            firstSpecimen.InventoryItem.Visibility.Should().Be(Visibility.Public);
            firstSpecimen.InventoryItem.CreatedBy.Should().Be(Helpers.UserId);
            firstSpecimen.InventoryItem.ModifiedBy.Should().Be(null);
            firstSpecimen.InventoryItem.DateAcquired.Should().Be(new DateTime(2020, 03, 31));
            firstSpecimen.InventoryItem.DateCreated.Should().Be(new DateTime(2020, 06, 15));
            firstSpecimen.InventoryItem.DateModified.Should().Be(null);
            firstSpecimen.InventoryItem.User.Id.Should().Be(1);
        }
Beispiel #3
0
        public static Mock <ISpecimenService> GetStandardMockSpecimenService(IEnumerable <Specimen> result = null)
        {
            var mockSpecimenService = new Mock <ISpecimenService>();

            mockSpecimenService.Setup(s => s.GetSpecimenAsync(It.IsAny <int>(), It.IsAny <User>()))
            .ReturnsAsync(result.FirstOrDefault() ?? FakeSpecimens.Get().First().AsModel());

            return(mockSpecimenService);
        }
Beispiel #4
0
 public RepositoryTests()
 {
     MockEmergenceDbContext = GetMockEmergenceDbContext(FakeSpecimens.Get());
 }