This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public ValueTracker GetChangedPropertyList<T>(ChangeTracker changeTracker) | |
| { | |
| var changedPropList = | |
| changeTracker.Entries().Where(entry => | |
| entry.Entity.GetType() == typeof(T)).SelectMany(entry => entry.Properties) | |
| .Where(entry => entry.IsModified).Select(entry => | |
| new ValueTrackerItem(entry.Metadata.Name, entry.OriginalValue, entry.CurrentValue)); | |
| return new ValueTracker {Changes = changedPropList.ToList()}; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SET date=2018-10-19 & git log --all --author="Christopher Bauer" --after="%date% 00:00" --before "%date% 23:59" --oneline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const logger = require("./logger"); | |
| exports.sendResponse = function(result, err, res) { | |
| if(err) { | |
| console.log(err); | |
| } | |
| result.send(res); | |
| logger.info({ result: JSON.stringify(res) }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface IUserInfo { | |
| id: number; | |
| FirstName: string; | |
| LastName: string; | |
| Height: number; | |
| Weight: number; | |
| Sex: 'Male' | 'Female'; | |
| Waist: number; | |
| Wrist: number; | |
| Hip: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface IBodyMetrics { | |
| Height: number; | |
| Weight: number; | |
| Waist: number; | |
| Sex: 'Male' | 'Female'; | |
| Wrist: number; | |
| Hip: number; | |
| Forearm: number; | |
| } | |
| interface IUserInfo extends IBodyMetrics { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getSimpleLeanBodyWeight = (body: IBodyMetrics) => { | |
| //Note: For demonstration purposes, this calculation is simplified | |
| if (body.Sex === 'Male') { | |
| return body.Weight * 1.082 + 94.42 - body.Waist * 4.15; | |
| } else if(body.Sex === 'Female') { | |
| return body.Weight * 0.732 + 8.987 + body.Wrist / 3.140 – body.Waist * 0.157 - body.Hip * 0.249 + body.Forearm * 0.434; | |
| } | |
| return undefined; | |
| } | |
| const getBodyFatWeight = (body: IBodyMetrics) => body.Weight - getSimpleLeanBodyWeight(body); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const exampleMaleBody: IBodyMetrics = { sex: "Male", Weight: 200, Waist: 34 }; | |
| describe('getSimpleLeanBodyWeight', () => { | |
| it('Gets 169.72 for males with 200 weight and 34 waist', () => { | |
| //arrange | |
| const body = exampleMaleBody; | |
| //act | |
| const actual = getSimpleLeanBodyWeight(body); | |
| //assert | |
| expect(actual).toEqual(169.72); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const MyBodyFatPercentage: React.FC<{}> = () => { | |
| const [weight, setWeight] = useState<number | undefined>(); | |
| const [waist, setWaist] = useState<number | undefined>(); | |
| const [sex, setSex] = useState<'Male' | 'Female' | undefined>(); | |
| const bodyFatPercentage = useMemo(() => getBodyFatPercent({ Weight: weight, Sex: sex, Waist: waist }), [weight, sex, waist]); | |
| const handleSetSex = useCallback((event:React.ChangeEvent<HTMLSelectElement>) => { | |
| const sex = event.target.value; | |
| if(sex === 'Male' || sex === 'Female') { | |
| setSex(sex); | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { FC } from "react"; | |
| interface FilteredSearchProps {} | |
| export const FilteredSearch: FC<FilteredSearchProps> = (props) => <></>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { | |
| render, | |
| screen, | |
| } from "@testing-library/react"; | |
| import "@testing-library/jest-dom"; | |
| import { describe, test } from "@jest/globals"; | |
| describe("FilteredSearch", () => { | |
| test("Renders an input box", () => { | |
| //arrange |