Exemplo n.º 1
0
        public void Ignore_IndexedProperties()
        {
            var expected = new IndexedPropertyTestData();
            var result   = new IndexedPropertyTestData();

            DeepAssert.Equal(expected, result);
        }
Exemplo n.º 2
0
        public void NullablePrimitive_DontThrowIfSame()
        {
            int?expected = 5;
            int?result   = 5;

            DeepAssert.Equal(expected, result);
        }
Exemplo n.º 3
0
        public void Recursion_AreIgnored()
        {
            var expected = new RecursiveParentData();
            var result   = new RecursiveParentData();

            DeepAssert.Equal(expected, result);
        }
Exemplo n.º 4
0
        public void StaticProperties_DontThrowIfDifferent()
        {
            var expected = new StaticPropertyData();
            var result   = new StaticPropertyData();

            DeepAssert.Equal(expected, result);
        }
Exemplo n.º 5
0
        public void PrivateProperties_DontThrowIfDifferent()
        {
            var expected = new PrivatePropertyData(1);
            var result   = new PrivatePropertyData(2);

            DeepAssert.Equal(expected, result);
        }
Exemplo n.º 6
0
        public void NullablePrimitive_DontThrowIfBothNull()
        {
            int?expected = null;
            int?result   = null;

            DeepAssert.Equal(expected, result);
        }
        public void Serialization()
        {
            Exception exception;

            try
            {
                throw new Exception();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            var       formatter = new BinaryFormatter();
            Exception actual;

            using (var ms = new MemoryStream())
            {
                formatter.Serialize(ms, exception);
                ms.Seek(0, SeekOrigin.Begin);
                actual = (Exception)formatter.Deserialize(ms);
            }

            DeepAssert.Equal(exception, actual, "StackTrace", "TargetSite");
        }
Exemplo n.º 8
0
        public void Enum_DontThrowIfEqual()
        {
            var expected = EnumData.Cat;
            var result   = EnumData.Cat;

            DeepAssert.Equal(expected, result);
        }
Exemplo n.º 9
0
        public void Serialization()
        {
            foreach (var type in _exceptionTypes)
            {
                IApiException exception;

                try
                {
                    throw (ApiException)Activator.CreateInstance(type);
                }
                catch (ApiException ex)
                {
                    exception = ex;
                }

                var formatter = new BinaryFormatter();

                IApiException actual;

                using (var ms = new MemoryStream())
                {
                    formatter.Serialize(ms, exception);
                    ms.Seek(0, SeekOrigin.Begin);
                    actual = (IApiException)formatter.Deserialize(ms);
                }

                DeepAssert.Equal(exception, actual, "StackTrace", "TargetSite");
            }
        }
Exemplo n.º 10
0
        public void List_DontThrowIfSameContent()
        {
            var expected = new[] { 1 };
            var result   = new[] { 1 };

            DeepAssert.Equal(expected, result);
        }
Exemplo n.º 11
0
        public void it_should_pass_inspection_for_weekly_product()
        {
            var          inspectionId   = InspectionId.Create("inspection-identifier");
            LicencePlate licencePlate   = LicencePlate.Create("123-456");
            const string location       = "Kernow";
            var          inspectionTime = new DateTimeOffset(2020, 2, 15, 10, 00, 00, 00, TimeSpan.Zero);
            var          stream         = new object[] {
                new VehicleRegistered(licencePlate.ToString()),
                // In the past
                new VehicleBooked(
                    licencePlate: licencePlate.ToString(),
                    location: location,
                    start: inspectionTime.AddDays(-57).ToUnixTimeSeconds(),
                    finish: inspectionTime.AddDays(-50).ToUnixTimeSeconds()),
                // Covers current inspection
                new VehicleBooked(
                    licencePlate: licencePlate.ToString(),
                    location: location,
                    start: inspectionTime.AddDays(-2).ToUnixTimeSeconds(),
                    finish: inspectionTime.AddDays(5).ToUnixTimeSeconds()),
                // In the future
                new VehicleBooked(
                    licencePlate: licencePlate.ToString(),
                    location: location,
                    start: inspectionTime.AddDays(1).ToUnixTimeSeconds(),
                    finish: inspectionTime.AddDays(8).ToUnixTimeSeconds())
            };
            var vehicle = Vehicle.FromStream(licencePlate, stream);

            vehicle.Inspect(inspectionId, inspectionTime, licencePlate, location);

            DeepAssert.Equal(Array.Empty <object>(), vehicle.TakeChanges().ToArray());
        }
Exemplo n.º 12
0
        public async Task Post_adds_to_event_store()
        {
            // Arrange
            var driverToAdd = this.fixture.UniqueHireEvent();

            // Act =>
            await this.client.PostAsJsonAsync("/api/driver", driverToAdd);

            // pull fresh from DB
            var driverEvents = await this.fixture.GetDriverEventsFromDb(driverToAdd.DriverId);

            // Assert => one event with matching high level and BSON data
            Assert.Collection(driverEvents, actual =>
            {
                // Assert => expected event (top level)
                var expected = new EventStore
                {
                    DriverId = driverToAdd.DriverId,
                    Event    = DriverEventType.Hired
                };

                DeepAssert.Equal(expected, actual, "Id", "Data");
                BsonAssert.Equal(driverToAdd, actual.Data);
            });
        }
Exemplo n.º 13
0
        public async Task LoadVan_updates_event_store(string urlSegment, DriverEventType expectedType)
        {
            var driverId = await this.fixture.CreateDriverHiredEvent();

            // Act =>
            var response = await this.client.PostAsJsonAsync($"/api/driver/{driverId}/{urlSegment}", new { });

            // Assert => response code
            response.EnsureSuccessStatusCode();

            // Get events from DB
            var events = await this.fixture.GetDriverEventsFromDb(driverId);

            // Assert => two events (one for hire)
            Assert.Equal(2, events.Count);

            var actual   = events[1];
            var expected = new EventStore
            {
                DriverId = driverId,
                Event    = expectedType
            };

            DeepAssert.Equal(expected, actual, "Id", "Data");
        }
Exemplo n.º 14
0
        public async Task SeededWater_InsertOrUpdate_IngredientUpdated()
        {
            //Arrange
            var ingredient = new IngredientDetailModel
                             (
                Name: IngredientSeeds.Water.Name,
                Description: IngredientSeeds.Water.Description
                             )
            {
                Id = IngredientSeeds.Water.Id
            };

            ingredient.Name        += "updated";
            ingredient.Description += "updated";

            //Act
            await _ingredientFacadeSUT.SaveAsync(ingredient);

            //Assert
            await using var dbxAssert = await DbContextFactory.CreateDbContextAsync();

            var ingredientFromDb = await dbxAssert.Ingredients.SingleAsync(i => i.Id == ingredient.Id);

            DeepAssert.Equal(ingredient, Mapper.Map <IngredientDetailModel>(ingredientFromDb));
        }
Exemplo n.º 15
0
        public async Task GetAll_Single_SeededWater()
        {
            var ingredients = await _ingredientFacadeSUT.GetAsync();

            var ingredient = ingredients.Single(i => i.Id == IngredientSeeds.Water.Id);

            DeepAssert.Equal(Mapper.Map <IngredientListModel>(IngredientSeeds.Water), ingredient);
        }
Exemplo n.º 16
0
        public void CanGetHandler()
        {
            var expected = new TestHandler();

            var actual = Sut <TestHandler>().GetHandler("test", new InMemoryConfiguration(), new ResponseContext());

            DeepAssert.Equal(expected, actual);
        }
Exemplo n.º 17
0
        public void CanGetHandlerWithDefaultArguments()
        {
            var expected = new TestHandlerWithMultipleArguments(null, null, null, 0);

            var actual = Sut <TestHandlerWithMultipleArguments>().GetHandler("test", null, null);

            DeepAssert.Equal(expected, actual);
        }
Exemplo n.º 18
0
        public async Task ApplicantChangeInfo()
        {
            var applicant = await CreateApplicantAsync();

            var info       = _fixture.Create <Info>();
            var actualInfo = await Client.ChangeApplicantDataAsync(applicant.Id, null, info);

            DeepAssert.Equal(actualInfo, info);
        }
Exemplo n.º 19
0
        public async Task ApplicantAddIdDocs(string documentFilePath, string documentContentType)
        {
            var applicant = await CreateApplicantAsync();

            var idDoc       = _fixture.Create <IdDoc>();
            var actualIdDoc = await AddApplicantIdDoc(applicant.Id, idDoc, documentFilePath, documentContentType);

            DeepAssert.Equal(actualIdDoc, idDoc);
        }
Exemplo n.º 20
0
        public async Task ApplicantSetIdDocs()
        {
            var applicant = await CreateApplicantAsync();

            var idDocs       = _fixture.Create <ApplicantIdDocs>();
            var actualIdDocs = await Client.SetApplicantIdDocsAsync(applicant.Id, idDocs);

            DeepAssert.Equal(actualIdDocs, idDocs);
        }
Exemplo n.º 21
0
        public async Task ApplicantCreate()
        {
            var model     = _fixture.Create <ApplicantRequest>();
            var applicant = await Client.CreateApplicantAsync(model);

            DeepAssert.Equal(applicant.Info, model.Info);

            Assert.Equal("test-api", applicant.Env);
        }
Exemplo n.º 22
0
        public void MapMapEqual()
        {
            var from = new IpGeo {
                ContinentCode = "a", CountryCode = "b", Latitude = 1, Longitude = 2, YourIp = "0.3.0.0", Timestamp = DateTimeOffset.UtcNow
            };
            var toFrom = from.To <IpGeoTableEntity>().To <IpGeo>();

            DeepAssert.Equal(from, toFrom);
        }
Exemplo n.º 23
0
    public void SanitizePathString(string path, string expectedPath)
    {
        // Given
        // When
        var actual = _operatingSystemLayerLinux.SanitizePath(path);

        // Then
        DeepAssert.Equal(expectedPath, actual);
    }
Exemplo n.º 24
0
        public void NullablePrimitive_ThrowIfResultOnlyNull()
        {
            int?expected = 5;
            int?result   = null;

            Assert.Throws <DeepAssertException>(() =>
            {
                DeepAssert.Equal(expected, result);
            });
        }
Exemplo n.º 25
0
        public async Task ApplicantGetIdDocs()
        {
            var applicant = await CreateApplicantAsync();

            var applicationIdDocs = await CreateApplicantIdDocs(applicant);

            var actualIdDocs = await Client.SetApplicantIdDocsAsync(applicant.Id, null);

            DeepAssert.Equal(actualIdDocs, applicationIdDocs);
        }
Exemplo n.º 26
0
        public void CanGetHandlerWithServices()
        {
            var expected = new TestHandlerWithServices(new TestService {
                Test = "Test"
            });

            var actual = Sut <TestHandlerWithServices>().GetHandler("test", null, null);

            DeepAssert.Equal(expected, actual);
        }
        public void CanBreakPipeline()
        {
            var sut = Sut(typeof(TestHandlerBreaks), typeof(TestHandler1));

            var expected = TestHandlerBreaks.Response;

            var actual = sut.HandleAsync(RouteContext).Result;

            DeepAssert.Equal(expected, actual);
        }
        public void AllowHandlerToReturnNull()
        {
            var sut = Sut(typeof(TestHandlerNull));

            var expected = new ResponseContext();

            var actual = sut.HandleAsync(RouteContext).Result;

            DeepAssert.Equal(expected, actual);
        }
        public void CanRunPipelineWithMultipleHandlers()
        {
            var sut = Sut(typeof(TestHandler1), typeof(TestHandler2));

            var expected = TestHandler2.Response;

            var actual = sut.HandleAsync(RouteContext).Result;

            DeepAssert.Equal(expected, actual);
        }
        public void CanPassPreviousResponseToHandler()
        {
            var sut = Sut(typeof(TestHandler1), typeof(TestHandlerWithPreviousResponse));

            var expected = TestHandler1.Response;

            var actual = sut.HandleAsync(RouteContext).Result;

            DeepAssert.Equal(expected, actual);
        }